From 6b24abdbd50dd1d12fc06405235a7c9f0079de07 Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Sat, 5 Mar 2022 22:34:34 -0600 Subject: [PATCH] Add io helper functions --- sw/io.c | 6 ++++++ sw/io.h | 11 ++++++++++- sw/main.c | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 sw/io.c diff --git a/sw/io.c b/sw/io.c new file mode 100644 index 0000000..685a771 --- /dev/null +++ b/sw/io.c @@ -0,0 +1,6 @@ +#include + +int io_remap(int region) { + *(unsigned char*)IO_REMAP = region; + return (*(unsigned char*)IO_REMAP == region); +} diff --git a/sw/io.h b/sw/io.h index c46ae2c..798c026 100644 --- a/sw/io.h +++ b/sw/io.h @@ -1,6 +1,15 @@ #ifndef _IO_H #define IO_H -#define IO_REMAP *(unsigned char*)0x7f00 + +#define IO_REMAP 0x7f00 + + +enum io_regions { + io_region_de10lite = 0, +}; + + +int io_remap(int region); #endif diff --git a/sw/main.c b/sw/main.c index 0125093..296b1c6 100644 --- a/sw/main.c +++ b/sw/main.c @@ -1,5 +1,6 @@ #include int main() { - IO_REMAP = 1; + io_remap(io_region_de10lite); + return 0; }