diff --git a/vmm/operation.c b/vmm/operation.c index 9a7f6b123c0fb1fa999267e550abc09d72e3703d..d68c7c0a9f92ede1b57838170c329daaceb4e8af 100644 --- a/vmm/operation.c +++ b/vmm/operation.c @@ -31,16 +31,16 @@ state_t STATE_GFX_INIT[] = { state_t STATE_IDE[] = { - { OP_READ_INJECT, REG_IDE_ST, 0, 1, op_callback_ide_prepare }, + { OP_READ_INJECT, REG_IDE_ST, 0x40, 1, op_callback_ide_prepare }, { OP_WRITE_EQUAL, REG_IDE_DATA + 2, 1, 1, NULL }, { OP_WRITE_STORE, REG_IDE_DATA + 3, 0, 1, op_callback_ide_store_sector_1 }, { OP_WRITE_STORE, REG_IDE_DATA + 4, 0, 1, op_callback_ide_store_sector_2 }, { OP_WRITE_STORE, REG_IDE_DATA + 5, 0, 1, op_callback_ide_store_sector_3 }, { OP_WRITE_STORE, REG_IDE_DATA + 6, 0, 1, op_callback_ide_store_sector_4 }, { OP_WRITE_EQUAL, REG_IDE_CMD, 0x30, 1, NULL }, - { OP_READ_INJECT, REG_IDE_ST, 0, 1, NULL }, + { OP_READ_INJECT, REG_IDE_ST, 0x40, 1, NULL }, { OP_WRITE_STORE_LOOP, REG_IDE_DATA, 0, 2, op_callback_ide_store_data }, - { OP_EMUL_END, 0, 0, 0, op_callback_ide_condlude }, + { OP_EMUL_END, 0, 0, 0, op_callback_ide_conclude }, }; state_t *STATE_ALL_STARTERS[] = { @@ -57,7 +57,7 @@ static hyper_init_gfx_params_t param_gfx_init; static hyper_ide_params_t param_ide; // store the index of the actual loop -static uint32_t loop_ide_data; +static uint32_t loop_ide_data = MAX_LOOP_IDE_DATA; static uint16_t buf_ide_data[MAX_LOOP_IDE_DATA]; // --- STATIC FUNCTION --- @@ -70,7 +70,7 @@ void op_callback_console_conclude(void *addr) { hyper_virtual_console_params_t *p_consol = (hyper_virtual_console_params_t *)addr; - printf("action : sending a message...\n"); + printf("OPERATION : sending a message...\n"); printf("%s\n", (char *)p_consol->msg); } @@ -83,7 +83,7 @@ void op_callback_timer_conclude(void *addr) { hyper_timer_sleep_params_t *p_timer = (addr == NULL) ? ¶m_timer : (hyper_timer_sleep_params_t *)addr; - printf("action : setting up a %dus timer...\n", p_timer->us); + printf("OPERATION : setting up a %dus timer...\n", p_timer->us); usleep(p_timer->us); } @@ -101,7 +101,7 @@ void op_callback_gfx_init_conclude(void *addr) { hyper_init_gfx_params_t *p_gfx_init = (addr == NULL) ? ¶m_gfx_init : (hyper_init_gfx_params_t *)addr; - printf("action : initializing gfx %dx%d...\n", p_gfx_init->width, p_gfx_init->height); + printf("OPERATION : initializing gfx %dx%d...\n", p_gfx_init->width, p_gfx_init->height); width_gfx = p_gfx_init->width; height_gfx = p_gfx_init->height; sem_post(&sem_gfx); @@ -133,7 +133,7 @@ void op_callback_ide_store_sector_3(void *addr) { void op_callback_ide_store_sector_4(void *addr) { param_ide.sector_idx |= ((*(uint8_t *)addr) & 0x0F) << 24; - // TODO: what to do with the mode ? + // WARNING: what to do with the mode ? } void op_callback_ide_store_data(void *addr) { @@ -148,10 +148,10 @@ void op_callback_ide_store_data(void *addr) { } } -void op_callback_ide_condlude(void *addr) { +void op_callback_ide_conclude(void *addr) { hyper_ide_params_t *p_ide = (addr == NULL) ? ¶m_ide : (hyper_ide_params_t *)addr; - printf("action : writing on 0x%lx on sector %d\n", p_ide->data, p_ide->sector_idx); + printf("OPERATION : writing data on sector %d\n", p_ide->sector_idx); // check sector range if (p_ide->sector_idx > MAX_SECTOR_NUM) err(1, "IDE sector is out of range"); @@ -164,15 +164,15 @@ void op_callback_ide_condlude(void *addr) { // Seek to the sector position if (fseek(disk, offset, SEEK_SET) != 0) { - err(1, "IDE seek failed"); fclose(disk); + err(1, "IDE seek failed"); } // Write 512 bytes to the specified sector size_t bytes_written = fwrite((void *)p_ide->data, 1, SECTOR_SIZE, disk); if (bytes_written != SECTOR_SIZE) { - err(1, "IDE failed to write full sector"); fclose(disk); + err(1, "IDE failed to write full sector"); } fclose(disk); diff --git a/vmm/operation.h b/vmm/operation.h index ff9af8186e2adc29e4d01d7edbcd150819afc155..f37e0acd8be515aa95ea76e00ed2dd99aef33507 100644 --- a/vmm/operation.h +++ b/vmm/operation.h @@ -10,7 +10,7 @@ // --- DEFINE --- -#define STATE_MACHINE_NUM 2 +#define STATE_MACHINE_NUM 3 typedef enum { @@ -24,7 +24,7 @@ typedef enum { typedef struct { operation_t op; // the operation to perform - uint32_t addr; // the address written to/read from + uint64_t addr; // the address written to/read from uint32_t value; // the expected written value or value to inject uint8_t size; // the size of the operation (8, 16 or 32 bits) void (*callback)(void *addr); // custom function that would be executed at the end of the state @@ -102,6 +102,6 @@ void op_callback_ide_store_sector_4(void *addr); void op_callback_ide_store_data(void *addr); -void op_callback_ide_condlude(void *addr); +void op_callback_ide_conclude(void *addr); #endif // _OPERATION_H_