2022-02-19 09:10:48 +03:00
|
|
|
/*
|
|
|
|
(C) M. Ærþ.
|
|
|
|
*/
|
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
|
|
|
|
2022-02-19 09:10:48 +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) {
|
2022-02-19 09:10:48 +03:00
|
|
|
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);
|
2022-02-19 09:10:48 +03:00
|
|
|
#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);
|
2022-02-19 09:10:48 +03:00
|
|
|
#ifdef LIVMDEBUG
|
|
|
|
puts("dev_delete");
|
|
|
|
#endif
|
2022-02-15 21:55:22 +03:00
|
|
|
}
|