4 Commits

Author SHA1 Message Date
9eae2e1005 Merge pull request #84 from shoshta73/RWXPerms
[fix] LOAD segment with RWX permissions
2025-12-30 17:19:16 -08:00
Borna Šoštarić
bd4236ad9b fix RWX perms warnings in link step 2025-12-31 01:39:18 +01:00
5292808934 Merge pull request #83 from vmttmv/main
Fix BL disk read status polls
2025-12-30 16:13:42 -08:00
vmttmv
09c48c2f50 fix stage2.asm: disk reads wait for BSY 2025-12-30 05:08:54 +02:00
2 changed files with 31 additions and 10 deletions

View File

@@ -40,6 +40,13 @@ ata_lba_read:
push edx push edx
push edi push edi
; Wait BSY=0 before proceeding to write the regs
.wait_rdy:
mov edx, 0x1F7
in al, dx
test al, 0x80
jnz .wait_rdy
mov eax, [ebp+8] ; arg #1 = LBA mov eax, [ebp+8] ; arg #1 = LBA
mov cl, [ebp+12] ; arg #2 = # of sectors mov cl, [ebp+12] ; arg #2 = # of sectors
mov edi, [ebp+16] ; arg #3 = buffer address mov edi, [ebp+16] ; arg #3 = buffer address
@@ -74,21 +81,23 @@ ata_lba_read:
mov al, 0x20 ; Read with retry. mov al, 0x20 ; Read with retry.
out dx, al out dx, al
mov bl, cl ; Save # of sectors in BL mov bl, cl ; Save # of sectors in BL
.wait_drq: .wait_rdy2:
mov edx, 0x1F7 mov edx, 0x1F7
.do_wait_drq: .do_wait_rdy2:
in al, dx in al, dx
test al, 8 ; the sector buffer requires servicing. test al, 0x80 ; BSY?
jz .do_wait_drq ; keep polling until the sector buffer is ready. jnz .do_wait_rdy2
test al, 0x8 ; DRQ?
jz .do_wait_rdy2
mov edx, 0x1F0 ; Data port, in and out mov edx, 0x1F0 ; Data port, in and out
mov ecx, 256 mov ecx, 256
rep insw ; in to [RDI] rep insw ; in to [RDI]
dec bl ; are we... dec bl ; are we...
jnz .wait_drq ; ...done? jnz .wait_rdy2 ; ...done?
pop edi pop edi
pop edx pop edx

View File

@@ -1,18 +1,30 @@
ENTRY(kmain) ENTRY(kmain)
PHDRS {
text PT_LOAD FLAGS(5); /* Read + Execute */
rodata PT_LOAD FLAGS(4); /* Read only */
data PT_LOAD FLAGS(6); /* Read + Write */
}
SECTIONS { SECTIONS {
. = 1M; . = 1M;
.text : { .text : {
*(.text*) *(.text*)
} } :text
.rodata : {
*(.rodata*)
} :rodata
.data : {
*(.data*)
} :data
.rodata : { *(.rodata*) }
.data : { *(.data*) }
.bss : { .bss : {
*(.bss*) *(.bss*)
*(COMMON) *(COMMON)
} } :data
.stack (NOLOAD) : { .stack (NOLOAD) : {
. = ALIGN(4); . = ALIGN(4);