blob: de42328a4fbf730c566741edc20460bb3427caa1 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// A kelvin program that computes the checksum from a range of the memory.
#include <stddef.h>
#include <stdint.h>
const uint32_t kInput = 0x300000;
const uint32_t kOutput = 0x380000;
const int kImageWords = 320 * 240 / sizeof(uint32_t);
int main(int argc, char *argv[]) {
const uint32_t *input = (const uint32_t *)kInput;
uint32_t *output = (uint32_t *)kOutput;
uint32_t checksum = 0;
for (int i = 0; i < kImageWords; ++i) {
checksum += input[i];
}
*output = checksum;
// Flush the output value to the address 0x380000.
asm volatile("lw a5, %0" : : "m"(output));
asm volatile(".word 0x26078077"); // flushat a5
return 0;
}