Skip to content

Commit

Permalink
Switch to a ioXX_t type instead of using volatiles everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrs committed May 27, 2013
1 parent 43c5946 commit 2e9271e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void peek(char * arg) {
if (addr & 0b11) {
printl("Warning: Address 0x%x is not word-aligned" NEWLINE, addr);
} else {
printl("*0x%x = 0x%x" NEWLINE, addr, *(volatile unsigned*)addr);
printl("*0x%x = 0x%x" NEWLINE, addr, *(io32_t)addr);
}
} else {
printl("Invalid address `%s'" NEWLINE, arg);
Expand All @@ -88,7 +88,7 @@ void poke(char *arg) {

if ( endptr != nextarg ) {
if (!(addr & 0b11)) {
*(volatile unsigned*)addr = value;
*(io32_t)addr = value;
}
} else {
if (*nextarg == ' ') nextarg++;
Expand Down
4 changes: 4 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@

#define NEWLINE "\r\n"

typedef volatile uint32_t *io32_t;
typedef volatile uint16_t *io16_t;
typedef volatile uint8_t *io8_t;

struct params {
struct {
void* addr; /* Where the kernel is loaded (address should be in range of mem_block) */
Expand Down
4 changes: 2 additions & 2 deletions trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "common.h"


static volatile unsigned * const vectaddr_begin = (volatile unsigned*)0x00000020;
static const io32_t vectaddr_begin = (io32_t)0x00000020;
static unsigned vectaddr_orig[3];

void trap_abt(void);
Expand Down Expand Up @@ -89,7 +89,7 @@ void trap_enter(struct trap_regs *regs) {
wait_key_pressed();

while (1) {
*(volatile unsigned*)0x900A0008 = 2;
*(io32_t)0x900A0008 = 2;
}
}

Expand Down

0 comments on commit 2e9271e

Please sign in to comment.