Actually use reassigned memory in kstdlib.c:vector_push()
This commit is contained in:
parent
0f9a174d0e
commit
6e82ad6d00
|
|
@ -85,6 +85,9 @@ void vector_push(vector_t *vector, void *new_element){
|
||||||
((uint8_t *)(newptr))[i] = ((uint8_t *)vector->ptr)[i * vector->size];
|
((uint8_t *)(newptr))[i] = ((uint8_t *)vector->ptr)[i * vector->size];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void *tmp = vector->ptr;
|
||||||
|
vector->ptr = newptr;
|
||||||
|
kfree(tmp);
|
||||||
}
|
}
|
||||||
for(uint32_t i = 0; i < vector->sizeof_elements; i++){
|
for(uint32_t i = 0; i < vector->sizeof_elements; i++){
|
||||||
((uint8_t *)(vector->ptr))[vector->size * vector->sizeof_elements + i] = ((uint8_t *)new_element)[i];
|
((uint8_t *)(vector->ptr))[vector->size * vector->sizeof_elements + i] = ((uint8_t *)new_element)[i];
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ uint32_t module_api(uint32_t func, ...){
|
||||||
vector_push(modules, structure);
|
vector_push(modules, structure);
|
||||||
pm_free(tmp);
|
pm_free(tmp);
|
||||||
return_value = 0;
|
return_value = 0;
|
||||||
// printf("Registered Key: %x", structure->key);
|
|
||||||
break;
|
break;
|
||||||
case MODULE_API_ADDINT:
|
case MODULE_API_ADDINT:
|
||||||
uint32_t int_index = va_arg(vars, uint32_t);
|
uint32_t int_index = va_arg(vars, uint32_t);
|
||||||
|
|
@ -39,12 +38,10 @@ uint32_t module_api(uint32_t func, ...){
|
||||||
return_value = -1;
|
return_value = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// printf("installed %d", int_index);
|
|
||||||
install_irq_handler(interrupt_handler, int_index);
|
install_irq_handler(interrupt_handler, int_index);
|
||||||
module_t *tmpmodule = vector_get(key & 0xff, modules);
|
module_t *tmpmodule = vector_get(key & 0xff, modules);
|
||||||
tmpmodule->interrupts |= 1 << int_index;
|
tmpmodule->interrupts |= 1 << int_index;
|
||||||
return_value = 0;
|
return_value = 0;
|
||||||
// printf("Added key\n");
|
|
||||||
break;
|
break;
|
||||||
case MODULE_API_DELINT:
|
case MODULE_API_DELINT:
|
||||||
int_index = va_arg(vars, uint32_t);
|
int_index = va_arg(vars, uint32_t);
|
||||||
|
|
@ -61,7 +58,6 @@ uint32_t module_api(uint32_t func, ...){
|
||||||
return_value = 0;
|
return_value = 0;
|
||||||
break;
|
break;
|
||||||
case MODULE_API_PRINT:
|
case MODULE_API_PRINT:
|
||||||
// vmlog(MODULE_NAME, "Testing modules calling kernel functions\n", MLOG_PRINT, vars);
|
|
||||||
char *name = va_arg(vars, char *);
|
char *name = va_arg(vars, char *);
|
||||||
char *string = va_arg(vars, char *);
|
char *string = va_arg(vars, char *);
|
||||||
vmlog(name, string, MLOG_PRINT, vars);
|
vmlog(name, string, MLOG_PRINT, vars);
|
||||||
|
|
@ -132,7 +128,6 @@ uint32_t module_api(uint32_t func, ...){
|
||||||
for(int i = 0; i < modules->size; i++){
|
for(int i = 0; i < modules->size; i++){
|
||||||
module_t* module = ((module_t *)vector_get(i, modules));
|
module_t* module = ((module_t *)vector_get(i, modules));
|
||||||
if(module->key == key){
|
if(module->key == key){
|
||||||
// printf("Adding message handler!!\n\n");
|
|
||||||
module->message_handler = handler;
|
module->message_handler = handler;
|
||||||
return_value = 0;
|
return_value = 0;
|
||||||
break;
|
break;
|
||||||
|
|
@ -167,13 +162,9 @@ void dispatch_message(uint32_t message, ...){
|
||||||
|
|
||||||
for(int i = 0; i < modules->size; i++){
|
for(int i = 0; i < modules->size; i++){
|
||||||
module_t *module = vector_get(i, modules);
|
module_t *module = vector_get(i, modules);
|
||||||
// int32_t (*handler)(uint32_t, ...) = ((module_t *)(vector_get(i, modules)))->key;
|
|
||||||
// uint32_t key = ((module_t *)(vector_get(i, modules)))->key;
|
|
||||||
uint32_t key = module->key;
|
uint32_t key = module->key;
|
||||||
int32_t (*handler)(uint32_t, ...) = module->message_handler;
|
int32_t (*handler)(uint32_t, ...) = module->message_handler;
|
||||||
if(!handler) continue;
|
if(!handler) continue;
|
||||||
// printf("Handler: %x, Key: %x\n", handler, key);
|
|
||||||
// for(;;);
|
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
vfile_t *srcfile;
|
vfile_t *srcfile;
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,9 @@ int ata_write(vfile_t *file, void *ptr, uint32_t offset, uint32_t count){
|
||||||
// api(MODULE_API_PRINT, MODULE_NAME, "PRDT (Read back from busmaster): %x\n", test);
|
// api(MODULE_API_PRINT, MODULE_NAME, "PRDT (Read back from busmaster): %x\n", test);
|
||||||
outb(bm_base, 0x00);
|
outb(bm_base, 0x00);
|
||||||
|
|
||||||
while(!ata_ready(io_base, ctrl_base, drive.flags.slave << 4));
|
while(!ata_ready(io_base, ctrl_base, drive.flags.slave << 4)){
|
||||||
|
asm("int $32\n");
|
||||||
|
}
|
||||||
uint64_t lba = offset >> 9;
|
uint64_t lba = offset >> 9;
|
||||||
// uint64_t lba = 0;
|
// uint64_t lba = 0;
|
||||||
outb(io_base + ATA_DRIVE_HEAD, 0x40 | (drive.flags.slave << 4) | ((lba >> 24) & 0x0F));
|
outb(io_base + ATA_DRIVE_HEAD, 0x40 | (drive.flags.slave << 4) | ((lba >> 24) & 0x0F));
|
||||||
|
|
@ -287,6 +289,13 @@ int ata_write(vfile_t *file, void *ptr, uint32_t offset, uint32_t count){
|
||||||
uint8_t bm_status = inb(bm_base + 2);
|
uint8_t bm_status = inb(bm_base + 2);
|
||||||
|
|
||||||
asm("int $32\n");
|
asm("int $32\n");
|
||||||
|
|
||||||
|
while(!ata_ready(io_base, ctrl_base, drive.flags.slave << 4)){
|
||||||
|
asm("int $32\n");
|
||||||
|
}
|
||||||
|
outb(io_base + ATA_DRIVE_HEAD, 0x40 | (drive.flags.slave << 4));
|
||||||
|
outb(io_base + ATA_COMMAND, ATA_CMD_CACHE_FLUSH_EXT);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -329,7 +338,9 @@ int ata_read(vfile_t *file, uint8_t *ptr, uint32_t offset, uint32_t count) {
|
||||||
// api(MODULE_API_PRINT, MODULE_NAME, "PRDT (Read back from busmaster): %x\n", test);
|
// api(MODULE_API_PRINT, MODULE_NAME, "PRDT (Read back from busmaster): %x\n", test);
|
||||||
outb(bm_base, 0x08);
|
outb(bm_base, 0x08);
|
||||||
|
|
||||||
while(!ata_ready(io_base, ctrl_base, drive.flags.slave << 4));
|
while(!ata_ready(io_base, ctrl_base, drive.flags.slave << 4)){
|
||||||
|
asm("int $32\n");
|
||||||
|
}
|
||||||
uint64_t lba = offset >> 9;
|
uint64_t lba = offset >> 9;
|
||||||
// uint64_t lba = 0;
|
// uint64_t lba = 0;
|
||||||
outb(io_base + ATA_DRIVE_HEAD, 0x40 | (drive.flags.slave << 4) | ((lba >> 24) & 0x0F));
|
outb(io_base + ATA_DRIVE_HEAD, 0x40 | (drive.flags.slave << 4) | ((lba >> 24) & 0x0F));
|
||||||
|
|
@ -410,6 +421,9 @@ cpu_registers_t *int_handler(cpu_registers_t * regs){
|
||||||
api(MODULE_API_UNBLOCK_PID, transferring_pid);
|
api(MODULE_API_UNBLOCK_PID, transferring_pid);
|
||||||
transferring_pid = 0;
|
transferring_pid = 0;
|
||||||
primary_ata_locked = 0;
|
primary_ata_locked = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return regs;
|
return regs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue