blob: f9b0cebd99ee3880d1b36a276e7a5708166f5af7 [file] [log] [blame]
// Copyright 2023 Google LLC.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// 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;
}