Fixed over-allocating memory that ends up being unused
This commit is contained in:
parent
1705096d91
commit
c19b4ffc6f
6
makefile
6
makefile
|
|
@ -14,9 +14,9 @@ all: bootloader tools kernel
|
|||
# ./diskwrite idm.elf ifsm.elf kernel.elf initrc.conf -o image.bin
|
||||
./diskwrite initrd.rd kernel.elf -o image.bin
|
||||
sudo mount image.bin mount
|
||||
sudo mkdir mount/mod # for kernel modules
|
||||
sudo mkdir mount/bin # for binary executables
|
||||
sudo mkdir mount/sys # for system files
|
||||
# sudo mkdir mount/mod # for kernel modules
|
||||
# sudo mkdir mount/bin # for binary executables
|
||||
# sudo mkdir mount/sys # for system files
|
||||
# ./diskwrite -v -o image.bin
|
||||
# ./diskwrite -v -l kernel.elf idm.elf -o image.bin
|
||||
qemu-system-i386 -hda image.bin -hdc test.bin --no-reboot --no-shutdown -m 32m -smp 2 -serial mon:stdio -D intlog.txt -d int
|
||||
|
|
|
|||
|
|
@ -25,11 +25,10 @@ uint32_t pm_alloc(){
|
|||
}
|
||||
}
|
||||
uint32_t pm_alloc_index(uint32_t index){
|
||||
// printf("%x\n", index);
|
||||
for(uint32_t i = index; i < index + 2; i++){
|
||||
for(uint32_t i = 0; i < 2; i++){
|
||||
for(int j = 0; j < 8; j++){
|
||||
// if(!(pm_map[i] & (1 << j))){
|
||||
pm_map[i] |= (1 << j);
|
||||
pm_map[i + index] |= (1 << j);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +38,9 @@ uint32_t pm_alloc_64kaligned(){
|
|||
uint32_t cont = 0;
|
||||
uint32_t current = 0;
|
||||
for(uint32_t i = 0; i < mmap_count; i++){
|
||||
// printf("Index: %x\n", i);
|
||||
if(i & 1 && cont < 1){
|
||||
continue;
|
||||
}
|
||||
for(int j = 0; j < 8; j++){
|
||||
if(!(pm_map[i] & (1 << j))){
|
||||
continue;
|
||||
|
|
@ -50,7 +51,6 @@ uint32_t pm_alloc_64kaligned(){
|
|||
}
|
||||
}
|
||||
if(cont == 1){
|
||||
// printf("Allocating index: %x (%x)\n", i, pm_map[i]);
|
||||
return pm_alloc_index(current);
|
||||
}
|
||||
current = i;
|
||||
|
|
|
|||
|
|
@ -475,6 +475,8 @@ uint8_t ata_identify(uint32_t index, uint16_t disk){
|
|||
if(drives[i].type == TYPE_IDE) ata_drives++;
|
||||
}
|
||||
drives[index].type = TYPE_IDE;
|
||||
uint32_t prdt_phys = api(MODULE_API_PMALLOC64K);
|
||||
drives[index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_phys, 16);
|
||||
itoa(ata_drives, fname + strlen(fname), 10);
|
||||
vfile_t *new_file = fcreate(api, fname, VFILE_DEVICE, ata_write, ata_read);
|
||||
new_file->mount_id = index;
|
||||
|
|
@ -503,15 +505,6 @@ void ide_init(uint32_t BARS[5]){
|
|||
drives[secondary_index].BARs[4] = BARS[4];
|
||||
drives[secondary_slave_index].BARs[4] = BARS[4];
|
||||
drives[secondary_slave_index].flags.slave = 1;
|
||||
|
||||
uint32_t prdt_primary_paddr = api(MODULE_API_PMALLOC64K);
|
||||
uint32_t prdt_primary_slave_paddr = api(MODULE_API_PMALLOC64K);
|
||||
uint32_t prdt_secondary_paddr = api(MODULE_API_PMALLOC64K);
|
||||
uint32_t prdt_secondary_slave_paddr = api(MODULE_API_PMALLOC64K);
|
||||
drives[primary_index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_primary_paddr, 16);
|
||||
drives[primary_slave_index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_primary_slave_paddr, 16);
|
||||
drives[secondary_index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_secondary_paddr, 16);
|
||||
drives[secondary_slave_index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_secondary_slave_paddr, 16);
|
||||
//now call ATA IDENTIFY
|
||||
uint8_t master_status = ata_identify(primary_index, ATA_MASTER);
|
||||
uint8_t slave_status = ata_identify(primary_slave_index, ATA_SLAVE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue