From b7078be3af95730ba18054e6f67aaafb775cb048 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 17 Jan 2019 01:07:27 +0100 Subject: [PATCH] Correcting a bug with ata driver --- boot/loader/cpu/cpu.asm | 9 +++++++++ boot/loader/io/ata.asm | 23 +++++++++++------------ boot/loader/io/rmterm.asm | 2 +- boot/loader/loader.asm | 5 +++++ build/bin/disk.img | Bin 18944000 -> 18944000 bytes build/bin/loader.bin | Bin 1966 -> 1992 bytes build/obj/boot/loader.bin | Bin 1966 -> 1992 bytes 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/boot/loader/cpu/cpu.asm b/boot/loader/cpu/cpu.asm index 206097a..e9b5274 100644 --- a/boot/loader/cpu/cpu.asm +++ b/boot/loader/cpu/cpu.asm @@ -20,3 +20,12 @@ temporize: loop .looping pop rcx ret + +bitemporize: + push rcx + mov rcx, 2000 +.looping: + call temporize + loop .looping + pop rcx + ret diff --git a/boot/loader/io/ata.asm b/boot/loader/io/ata.asm index bc9c2ef..9f6aaed 100644 --- a/boot/loader/io/ata.asm +++ b/boot/loader/io/ata.asm @@ -34,7 +34,7 @@ ;; GLOBAL DATA Bootdrv db 0 -end db "[End of Sector]", 0x0 +end db "[End of Sector]", 0x0A, 0x0D, 0x0 buffer: times 513 db "_" ;; TEXT @@ -42,8 +42,8 @@ buffer: times 513 db "_" ata_read: ;-----------------------------------------------------------------------; ; x64/LM ATA Reading function ; -; ; -; ; +; bl : number of sectors to read XXX ; +; bh : the first sector to read ; ;-----------------------------------------------------------------------; ; Technical infos about the ports (Intel Doc): @@ -84,22 +84,21 @@ ata_read: ; 32h write long with retry ; 33h write long without retry ; - push rax push rbx - push rdx push rcx + push rdx push rdi mov dx, 0x1f6 ; Drive and head port mov al, 0x0a0 ; Drive 0, head 0 out dx,al mov dx, 0x1f2 ; Sector count port - mov al, 1 ; Read one sector + mov al, bl ; Read bl(s) sector out dx, al mov dx, 0x1f3 ; Sector number port - mov al, 1 ; Read sector one + mov al, bh ; Read from sector n°bh out dx, al mov dx, 0x1f4 ; Cylinder low port @@ -121,18 +120,18 @@ still_going: ;is ready. mov cx, 512/2 ; One sector /2 because it copies words - mov rdi, buffer + mov rdi, QWORD buffer mov dx, 0x1f0 ; Data port - data comes in and out of here. rep insw pop rdi - pop rcx - pop rdx - pop rbx - pop rax mov bl, 0x0F mov esi, buffer call dump mov bl, 0x0A mov esi, end call write + pop rdx + pop rcx + pop rbx + pop rax ret diff --git a/boot/loader/io/rmterm.asm b/boot/loader/io/rmterm.asm index 7bedfca..62f1b8a 100644 --- a/boot/loader/io/rmterm.asm +++ b/boot/loader/io/rmterm.asm @@ -40,7 +40,7 @@ PrintB: ;---------------------------------------------------; ; Print out a simple string. ; ; ; -; Expects: DS:SI = String to print ; +; DS:SI = String to print ; ; ; ; Returns: None ; ; ; diff --git a/boot/loader/loader.asm b/boot/loader/loader.asm index 897ba5a..a2bb849 100644 --- a/boot/loader/loader.asm +++ b/boot/loader/loader.asm @@ -224,8 +224,13 @@ main64: call write call temporize ; Temporized because the ATA drive must be ready + + mov bl, 1 + mov bh, 1 call ata_read + call bitemporize ; Temporized because the ATA drive must be ready + jmp Die ; times 1024 nop diff --git a/build/bin/disk.img b/build/bin/disk.img index d3916c3b23024e906cc1b5687cb89ac0fc947099..9c358523e8bbaca4b9d9434333ea44f8a2df44e9 100644 GIT binary patch delta 8231 zcmeHM3v^V~6@70)U=kz)2@)V0LTQSnLiq_ID%gq)h=dT4fe0yzkxvQM(poMN{xYDOzkQX+X!e+Lr$8uKigp{iGsq2r30CgpcDr_uW~(4nne4SY3*fwRYy@ z<-EMP`|N%0xsydTi?bFfY#tblb_`_K4h+6jvNAaEgLp%~UawdK#t#^8S@K$FZEt5; zJLg$_tum`bA!Mx{Voi#cZn!9vl2^NS!`#tz!5aIqw)qoFCs%HL*WO(7cIDQ6_R?3? z%YJ+5q3Cn_dOACwuyYF{WwoK$#?F@I&OVk%)Mm#XmU#EkM55g3#En=eKVSUbYY}S z{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c zx=7`FL{7q`;oj(qaG+BHm#W?Ms@-*k<-pDq7I)ti=$SSqHcNhj0(~dpOsaNLS@vh` zGVHg~Nb5-{tA0w7{x0jkOZ7J=>94W+y4rTI(KoRj_0x+? zH%|>`h&;5FG>u*KRXpzAUe~*}ckZBf`@{Kfro>?0gnJ1fsMf(i8gTujVz(0c{z-z&g;C0~j;0@r7;7#Bt za5Q)`cnf$dI0hUG-Uj{!ydAs)yb}aC4!jGz8@vY`4^9C83f>D&1Sf&_fs?^}a0)mT zydR8$4}gCIr-2WG4}sIc8Q@HC7Wj8?Huy032>2*i0L}sDg7d)n-~zA^{0F!Yd<|31}+Dm0-pw-0bQ^JTmh~Gp9NQetHCwkbKvvfKfxEkwctAN zMerr?W$+b{;H%(k;OpRe@D1=y@GbCda09pzd_I+yrh0 zKLb5529|Ud#+z##lcY?dXe}P|tUxT~BJ>XvO8}M83J1~9^1NSl@ zB`BqulGZfQ4N$AUH56JZ;xE#tjSJrS1B}*l`0$ zeP-M*|KH5DZx)FC`p^IWQIXLRhXZ$B zU}s>MFk!-@-;q$xix>a@|9|vzvMjq~eK%0uX6}8vg@Ae%gV_B0>_P15AU4;&b09WY z4gbDi5W5~I{(=Fba2`k?4@qGXh|Rn2E=W8Kq9zN(_5!kB!~-qe%($KL#ruCiUL273 KvgIe!|Nj6DEI delta 237 zcmX@Xzm9){FcYKFW)Y^TOpFYhH?sU;oP2iaG1$G98 z2@@tf`aM~XU9w^hP;fK%zTHAV1zSLD{(bf!_6iW2Yu`B#8?1(ZUoeP00Vw`L5TbA% nNT41`VKIo!yYDVYJRPDY3&f5FvR~x=2NFy`;^n-b|NjF3@W*-; diff --git a/build/obj/boot/loader.bin b/build/obj/boot/loader.bin index 39723e4850df1a06b50ed872260499334026f15f..94295b38065e9f2ccacaccf7c1b8e8f8d67199de 100644 GIT binary patch delta 264 zcmZ3-e}aF5FcYKkW)Y^TOw3%o44XHy{9>GZfQ4N$AUH56JZ;xE#tjSJrS1B}*l`0$ zeP-M*|KH5DZx)FC`p^IWQIXLRhXZ$B zU}s>MFk!-@-;q$xix>a@|9|vzvMjq~eK%0uX6}8vg@Ae%gV_B0>_P15AU4;&b09WY z4gbDi5W5~I{(=Fba2`k?4@qGXh|Rn2E=W8Kq9zN(_5!kB!~-qe%($KL#ruCiUL273 KvgIe!|Nj6DEI delta 237 zcmX@Xzm9){FcYKFW)Y^TOpFYhH?sU;oP2iaG1$G98 z2@@tf`aM~XU9w^hP;fK%zTHAV1zSLD{(bf!_6iW2Yu`B#8?1(ZUoeP00Vw`L5TbA% nNT41`VKIo!yYDVYJRPDY3&f5FvR~x=2NFy`;^n-b|NjF3@W*-;