Search
lxdream.org :: lxdream/src/mmio.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/mmio.h
changeset 929:fd8cb0c82f5f
prev796:a2dc83592467
next946:d41ee7994db7
author nkeynes
date Sat Dec 20 03:01:40 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change First pass experiment using cached decoding.
file annotate diff log raw
1.1 --- a/src/mmio.h Wed Jul 30 22:50:44 2008 +0000
1.2 +++ b/src/mmio.h Sat Dec 20 03:01:40 2008 +0000
1.3 @@ -16,8 +16,8 @@
1.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.5 * GNU General Public License for more details.
1.6 */
1.7 -#ifndef dream_mmio_H
1.8 -#define dream_mmio_H 1
1.9 +#ifndef lxdream_mmio_H
1.10 +#define lxdream_mmio_H 1
1.11
1.12 #ifdef __cplusplus
1.13 extern "C" {
1.14 @@ -28,6 +28,7 @@
1.15
1.16 #include <stdint.h>
1.17 #include <stdlib.h>
1.18 +#include "mem.h"
1.19
1.20 #define LXDREAM_PAGE_TABLE_ENTRIES 128*1024
1.21 #define LXDREAM_PAGE_SIZE 4096
1.22 @@ -45,8 +46,7 @@
1.23 struct mmio_region {
1.24 char *id, *desc;
1.25 uint32_t base;
1.26 - int32_t (*io_read)(uint32_t addr);
1.27 - void (*io_write)(uint32_t addr, uint32_t val);
1.28 + struct mem_region_fn fn;
1.29 char *mem;
1.30 char *save_mem; /* Used to compare for gui updates */
1.31 struct mmio_port {
1.32 @@ -112,7 +112,7 @@
1.33 #undef MMIO_REGION_LIST_BEGIN
1.34 #undef MMIO_REGION
1.35 #undef MMIO_REGION_LIST_END
1.36 -#define MMIO_REGION_BEGIN(b,id,d) struct mmio_region mmio_region_##id = { #id, d, b, mmio_region_##id##_read, mmio_region_##id##_write, 0, 0, {
1.37 +#define MMIO_REGION_BEGIN(b,id,d) struct mmio_region mmio_region_##id = { #id, d, b, {mmio_region_##id##_read, mmio_region_##id##_write,mmio_region_##id##_read, mmio_region_##id##_write,mmio_region_##id##_read, mmio_region_##id##_write,NULL, NULL}, 0, 0, {
1.38 #define LONG_PORT( o,id,f,def,d ) { #id, d, 32, o, def, f },
1.39 #define WORD_PORT( o,id,f,def,d ) { #id, d, 16, o, def, f },
1.40 #define BYTE_PORT( o,id,f,def,d ) { #id, d, 8, o, def, f },
1.41 @@ -125,14 +125,16 @@
1.42 * actually need any direct code on read and/or write
1.43 */
1.44 #define MMIO_REGION_READ_STUBFN( id ) \
1.45 -int32_t mmio_region_##id##_read( uint32_t reg ) { \
1.46 +int32_t FASTCALL mmio_region_##id##_read( uint32_t reg ) { \
1.47 + reg = reg & 0xFFF; \
1.48 int32_t val = MMIO_READ( id, reg ); \
1.49 WARN( "Read from unimplemented module %s (%03X => %08X) [%s: %s]",\
1.50 #id, reg, val, MMIO_REGID(id,reg), MMIO_REGDESC(id,reg) ); \
1.51 return val; \
1.52 }
1.53 #define MMIO_REGION_WRITE_STUBFN( id ) \
1.54 -void mmio_region_##id##_write( uint32_t reg, uint32_t val ) { \
1.55 +void FASTCALL mmio_region_##id##_write( uint32_t reg, uint32_t val ) { \
1.56 + reg = reg & 0xFFF; \
1.57 WARN( "Write to unimplemented module %s (%03X <= %08X) [%s: %s]", \
1.58 #id, reg, val, MMIO_REGID(id,reg), MMIO_REGDESC(id,reg) ); \
1.59 MMIO_WRITE( id, reg, val ); \
1.60 @@ -141,32 +143,26 @@
1.61 MMIO_REGION_READ_STUBFN( id ) \
1.62 MMIO_REGION_WRITE_STUBFN( id )
1.63 #define MMIO_REGION_READ_DEFFN( id ) \
1.64 -int32_t mmio_region_##id##_read( uint32_t reg ) { \
1.65 - return MMIO_READ( id, reg ); \
1.66 +int32_t FASTCALL mmio_region_##id##_read( uint32_t reg ) { \
1.67 + return MMIO_READ( id, reg&0xFFF ); \
1.68 }
1.69 #define MMIO_REGION_WRITE_DEFFN( id ) \
1.70 -void mmio_region_##id##_write( uint32_t reg, uint32_t val ) { \
1.71 - MMIO_WRITE( id, reg, val ); \
1.72 +void FASTCALL mmio_region_##id##_write( uint32_t reg, uint32_t val ) { \
1.73 + MMIO_WRITE( id, reg&0xFFF, val ); \
1.74 }
1.75 #define MMIO_REGION_DEFFNS( id ) \
1.76 MMIO_REGION_READ_DEFFN( id ) \
1.77 MMIO_REGION_WRITE_DEFFN( id )
1.78 #endif
1.79
1.80 -#define MMIO_REGION_WRITE_FN( id, reg, val ) \
1.81 -void mmio_region_##id##_write( uint32_t reg, uint32_t val )
1.82 -
1.83 -#define MMIO_REGION_READ_FN( id, reg ) \
1.84 -int32_t mmio_region_##id##_read( uint32_t reg )
1.85 -
1.86 #else
1.87
1.88 #ifndef MMIO_IFACE_INCLUDED
1.89 #define MMIO_IFACE_INCLUDED
1.90 #define MMIO_REGION_BEGIN(b,id,d) \
1.91 extern struct mmio_region mmio_region_##id; \
1.92 -int32_t mmio_region_##id##_read(uint32_t); \
1.93 -void mmio_region_##id##_write(uint32_t, uint32_t); \
1.94 +int32_t FASTCALL mmio_region_##id##_read(uint32_t); \
1.95 +void FASTCALL mmio_region_##id##_write(uint32_t, uint32_t); \
1.96 enum mmio_region_##id##_port_t {
1.97 #define LONG_PORT( o,id,f,def,d ) id = o,
1.98 #define WORD_PORT( o,id,f,def,d ) id = o,
1.99 @@ -177,5 +173,12 @@
1.100 #define MMIO_REGION_LIST_END
1.101 #endif
1.102
1.103 +#define MMIO_REGION_WRITE_FN( id, reg, val ) \
1.104 +void FASTCALL mmio_region_##id##_write( uint32_t reg, uint32_t val )
1.105 +
1.106 +#define MMIO_REGION_READ_FN( id, reg ) \
1.107 +int32_t FASTCALL mmio_region_##id##_read( uint32_t reg )
1.108 +
1.109 +
1.110 #endif
1.111
.