LIVM/devices.c

27 lines
502 B
C
Raw Permalink Normal View History

/*
(C) M. Æ.
*/
2022-02-15 21:55:22 +03:00
2022-04-09 00:20:48 +03:00
#define DEV_C 3
2022-02-15 21:55:22 +03:00
#include "device/clock.c"
#include "device/console.c"
2022-04-09 00:20:48 +03:00
#include "device/rom.c"
2022-02-15 21:55:22 +03:00
void dev_init(struct VMinst* vm) {
vm->devices = (struct IODevice*)malloc(sizeof(struct IODevice) * DEV_C);
setup_clock(vm);
2022-02-15 21:55:22 +03:00
setup_console(vm);
2022-04-09 00:20:48 +03:00
setup_rom(vm);
#ifdef LIVMDEBUG
puts("dev_init");
#endif
2022-02-15 21:55:22 +03:00
}
void dev_delete(struct VMinst* vm) {
for (uint64_t d = 0; d < DEV_C; d++) vm->devices[d].poweroff(vm);
free(vm->devices);
#ifdef LIVMDEBUG
puts("dev_delete");
#endif
2022-02-15 21:55:22 +03:00
}