Add files via upload

This commit is contained in:
Ærþ 2022-04-09 04:20:48 +07:00 committed by GitHub
parent d02a5d3dfd
commit 560bc596ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 1053 additions and 439 deletions

View file

@ -1,24 +1,26 @@
#define CLOCK vm->devices[0]
void clock_write(struct VMinst* vm, void* data, uint64_t length) {
printf("clock_write was called. [%p, %p, %lu]", vm, data, length);
exit(-1);
}
void clock_out(struct VMinst* vm) {
printf("clock_out was called. [%p]", vm);
exit(-1);
}
void clock_read(struct VMinst* vm, void* buffer, uint64_t length, uint64_t where) {
time(((time_t*)buffer));
}
void clock_wait(struct VMinst* vm, uint64_t data) {
usleep(data);
}
void clock_poweroff(struct VMinst* vm) {
#ifdef LLLIVMDEBUG
puts("clock_poweroff<");
puts("<clock_poweroff");
#endif
free(CLOCK.buffer);
#ifdef LLLIVMDEBUG

View file

@ -11,6 +11,7 @@ void console_write(struct VMinst* vm, void* data, uint64_t length) {
void console_out(struct VMinst* vm) {
puts((char*)(CONSOLE.buffer + 2));
((uint16_t*)CONSOLE.buffer)[0] = 0;
}
void console_read(struct VMinst* vm, void* buffer, uint64_t length, uint64_t where) {
@ -32,7 +33,7 @@ void console_wait(struct VMinst* vm, uint64_t data) {
void console_poweroff(struct VMinst* vm) {
#ifdef LLLIVMDEBUG
puts("console_poweroff<");
puts("<console_poweroff");
#endif
free(CONSOLE.buffer);
#ifdef LLLIVMDEBUG

44
device/rom.c Normal file
View file

@ -0,0 +1,44 @@
#define ROM vm->devices[2]
void rom_write(struct VMinst* vm, void* data, uint64_t length) {
printf("rom_write was called. [%p, %p, %lu]", vm, data, length);
exit(-1);
}
void rom_out(struct VMinst* vm) {
printf("rom_out was called. [%p]", vm);
exit(-1);
}
void rom_read(struct VMinst* vm, void* buffer, uint64_t length, uint64_t where) {
}
void rom_wait(struct VMinst* vm, uint64_t data) {
}
void rom_poweroff(struct VMinst* vm) {
#ifdef LLLIVMDEBUG
puts("<rom_poweroff");
#endif
free(ROM.buffer);
#ifdef LLLIVMDEBUG
puts("rom_poweroff>");
#endif
}
void setup_rom(struct VMinst* vm) {
ROM.buffer = malloc(1024 * 256);
ROM.write = &rom_write;
ROM.out = &rom_out;
ROM.read = &rom_read;
ROM.wait = &rom_wait;
ROM.poweroff = &rom_poweroff;
if (DEV_ROM_COUNT > 8) {
puts("Error: DEV_ROM_COUNT must be <= 8.");
exit(-1);
}
for (int i = 0; i < DEV_ROM_COUNT; ++i) {
((uint64_t**)ROM.buffer)[1024 * 32 - 8 + i] = (uint64_t*) fopen(dev_rom[i], "rb+");
}
}