summaryrefslogtreecommitdiff
path: root/emu/device.c
diff options
context:
space:
mode:
Diffstat (limited to 'emu/device.c')
-rw-r--r--emu/device.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/emu/device.c b/emu/device.c
new file mode 100644
index 0000000..ecf3d2d
--- /dev/null
+++ b/emu/device.c
@@ -0,0 +1,44 @@
+#include "device.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static device_vtable_t const device_vtable = {
+ device_read,
+ device_write,
+ device_deinit
+};
+
+void device_init( device_t *device, const char *name )
+{
+ device->name = strdup( name );
+
+ device->vtable = &device_vtable;
+}
+
+uint8_t device_read( void *obj, uint16_t addr )
+{
+ device_t *device = (device_t *)obj;
+
+ fprintf( stderr, "WARN: read access on abstract device '%s' on address %04X\n",
+ device->name, addr );
+
+ return 0;
+}
+
+void device_write( void *obj, uint16_t addr, uint8_t data )
+{
+ device_t *device = (device_t *)obj;
+
+ fprintf( stderr, "WARN: write access on abstract device '%s' on address %04X\n",
+ device->name, addr );
+}
+
+void device_deinit( void *obj )
+{
+ device_t *device = (device_t *)obj;
+
+ free( device->name );
+}
+