Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory map constants as defines #161

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add void to function signatures meant to be used without args
mchack-work authored and dehanj committed Mar 19, 2024
commit e085d0ebd03a4e8eef79fb5bb020172d03c25c3e
4 changes: 2 additions & 2 deletions hw/application_fpga/fw/testfw/main.c
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ uint32_t wait_timer_tick(uint32_t last_timer)
}
}

void zero_fwram()
void zero_fwram(void)
{
for (int i = 0; i < TK1_MMIO_FW_RAM_SIZE; i++) {
fw_ram[i] = 0x00;
@@ -149,7 +149,7 @@ void failmsg(char *s)
puts("\r\n");
}

int main()
int main(void)
{
// Function pointer to blake2s()
volatile int (*fw_blake2s)(void *, unsigned long, const void *,
14 changes: 7 additions & 7 deletions hw/application_fpga/fw/tk1/main.c
Original file line number Diff line number Diff line change
@@ -42,9 +42,9 @@ struct context {
uint8_t uss[32]; // User Supplied Secret, if any
};

static void print_hw_version();
static void print_hw_version(void);
static void print_digest(uint8_t *md);
static uint32_t rnd_word();
static uint32_t rnd_word(void);
static void compute_cdi(const uint8_t *digest, const uint8_t use_uss,
const uint8_t *uss);
static void copy_name(uint8_t *buf, const size_t bufsiz, const uint32_t word);
@@ -55,9 +55,9 @@ static enum state loading_commands(const struct frame_header *hdr,
const uint8_t *cmd, enum state state,
struct context *ctx);
static void run(const struct context *ctx);
static void scramble_ram();
static void scramble_ram(void);

static void print_hw_version()
static void print_hw_version(void)
{
htif_puts("Hello, I'm firmware with");
htif_puts(" tk1_name0:");
@@ -81,7 +81,7 @@ static void print_digest(uint8_t *md)
htif_lf();
}

static uint32_t rnd_word()
static uint32_t rnd_word(void)
{
while ((*trng_status & (1 << TK1_MMIO_TRNG_STATUS_READY_BIT)) == 0) {
}
@@ -362,7 +362,7 @@ static void run(const struct context *ctx)
__builtin_unreachable();
}

static void scramble_ram()
static void scramble_ram(void)
{
uint32_t *ram = (uint32_t *)(TK1_RAM_BASE);
uint32_t rnd = rnd_word();
@@ -384,7 +384,7 @@ static void scramble_ram()
*ram_scramble = rnd_word();
}

int main()
int main(void)
{
struct context ctx = {0};
struct frame_header hdr = {0};
2 changes: 1 addition & 1 deletion hw/application_fpga/fw/tk1/proto.c
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ static void write(uint8_t *buf, size_t nbytes)
}
}

uint8_t readbyte()
uint8_t readbyte(void)
{
for (;;) {
if (*can_rx) {
2 changes: 1 addition & 1 deletion hw/application_fpga/fw/tk1/proto.h
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ struct frame_header {
};

void writebyte(uint8_t b);
uint8_t readbyte();
uint8_t readbyte(void);
void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf);
int readcommand(struct frame_header *hdr, uint8_t *cmd, int state);
#endif