flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
dosin 25 Feb 2009, 19:50
edfed - are you using int 13h?
wont that limit it to 8 gigabytes on drives?? I think I am going to start with IDE drives .. detect number of drives and format my new disk with 4 portions.. and detect them.. for a start... The 1st program is going to be kind of like grub booted from a floppy or CD /DVD and try and boot XP and Vista from it.. if anyone knows of any good reading material or anything.. I have found some good info ,, but the more the better.. any pointers or any advice.. please share- even if you think there is a better way to start,, I am allways open for input - good or bad.. lol Thanks to anyone wanting to contribute or help with this project! |
|||
![]() |
|
edfed 26 Feb 2009, 09:51
dosin wrote: edfed - are you using int 13h? i use f.disk that use int13h for the moment. and yes, it limits the drive to 8GB, the size of my bigger USB pen. ![]() but it is not a problem because f.disk is limited to 2TB and as the revolution's contest say: use of BIOS/DOS ints is forbidden. about the f.disk function and my bootloader, it will load a .com binary from the floppy, somewhere in RM ram, execute it, and when it will finish this program, it will load the boot sector from the first drive (C: ) and then, it is like a reboot with another OS, tested with 98 and XP, OK! but 98, DOS and XP don't do that ![]() it would be easy to imagine a multidrive boot selector based on this principle. |
|||
![]() |
|
tom tobias 26 Feb 2009, 12:49
dosin wrote: ...if anyone knows of any good reading material or anything... has a link to a full specification for programming PCI IDE controllers. http://www.geocities.com/siliconvalley/2072/atapi.htm (accessing the two IDE controllers found on typical motherboards, since the mid 1990's, elaborates the different locations within each register on the IDE controllers corresponding to control of the read/write functions for the individual controllers on the hard drive itself.) chapter 9 of Master Class Assembly Language Programming offers some information of utility, despite a focus on FAT. http://openlibrary.org/b/OL8655157M Here is the web location of all the documents from the Technical Committee for the ATA interface. http://www.t13.org/ |
|||
![]() |
|
dosin 26 Feb 2009, 15:58
Excellent! I love information...
http://en.wikipedia.org/wiki/Master_boot_record On here I found a program thats named HxD its a hex editor that will read the entire Disk drive selected in Vista,XP ect.. and reads all the sectores.. and what is in each sector of the disks on my computers.. and a lot of other info on MBR and Drives ... edfed... even though your using that now.. you have a bases for it.. switching it from 13h should not be that hard... you have a good idea. and a good start on the code..! ![]() cant wait until I get that far! I have the shell of the program ready.. now for the important stuff.. ![]() |
|||
![]() |
|
Dex4u 27 Feb 2009, 18:07
Read/writing raw sectors is very easy from pmode without using bios
NOTE: DO NOT USE THIS CODE AS IS, TO WRITE SECTORS OR YOU WILL LOSE YOU MBR. Code: Reading the harddisk using ports! ; +-------------------------------+ by qark ; ; ; This took me months to get working but I finally managed it. ; ; This code only works for the 286+ so you must detect for 8088's somewhere ; in your code. ; ; Technical Information on the ports: ; Port Read/Write Misc ; ------ ------------ ------------------------------------------------- ; 1f0 r/w data register, the bytes are written/read here ; 1f1 r error register (look these values up yourself) ; 1f2 r/w sector count, how many sectors to read/write ; 1f3 r/w sector number, the actual sector wanted ; 1f4 r/w cylinder low, cylinders is 0-1024 ; 1f5 r/w cylinder high, this makes up the rest of the 1024 ; 1f6 r/w drive/head ; bit 7 = 1 ; bit 6 = 0 ; bit 5 = 1 ; bit 4 = 0 drive 0 select ; = 1 drive 1 select ; bit 3-0 head select bits ; 1f7 r status register ; bit 7 = 1 controller is executing a command ; bit 6 = 1 drive is ready ; bit 5 = 1 write fault ; bit 4 = 1 seek complete ; bit 3 = 1 sector buffer requires servicing ; bit 2 = 1 disk data read corrected ; bit 1 = 1 index - set to 1 each revolution ; bit 0 = 1 previous command ended in an error ; 1f7 w command register ; commands: ; 50h format track ; 20h read sectors with retry ; 21h read sectors without retry ; 22h read long with retry ; 23h read long without retry ; 30h write sectors with retry ; 31h write sectors without retry ; 32h write long with retry ; 33h write long without retry ; ; Most of these should work on even non-IDE hard disks. ; This code is for reading, the code for writing is the next article. mov dx,1f6h ;Drive and head port mov al,0a0h ;Drive 0, head 0 out dx,al mov dx,1f2h ;Sector count port mov al,1 ;Read one sector out dx,al mov dx,1f3h ;Sector number port mov al,1 ;Read sector one out dx,al mov dx,1f4h ;Cylinder low port mov al,0 ;Cylinder 0 out dx,al mov dx,1f5h ;Cylinder high port mov al,0 ;The rest of the cylinder 0 out dx,al mov dx,1f7h ;Command port mov al,20h ;Read with retry. out dx,al still_going: in al,dx test al,8 ;This means the sector buffer requires ;servicing. jz still_going ;Don't continue until the sector buffer ;is ready. mov cx,512/2 ;One sector /2 mov di,offset buffer mov dx,1f0h ;Data port - data comes in and out of here. rep insw ; ------ mov ax,201h ;Read using int13h then compare buffers. mov dx,80h mov cx,1 mov bx,offset buffer2 int 13h mov cx,512 mov si,offset buffer mov di,offset buffer2 repe cmpsb jne failure mov ah,9 mov dx,offset readmsg int 21h jmp good_exit failure: mov ah,9 mov dx,offset failmsg int 21h good_exit: mov ax,4c00h ;Exit the program int 21h readmsg db 'The buffers match. Hard disk read using ports.$' failmsg db 'The buffers do not match.$' buffer db 512 dup ('V') buffer2 db 512 dup ('L') ; ; Writing to the hard disk using the ports! by qark ; +---------------------------------------+ ; ; The only differences between reading and writing using the ports is ; that 30h is sent to the command register, and instead of INSW you ; OUTSW. ; mov dx,1f6h ;Drive and head port mov al,0a0h ;Drive 0, head 0 out dx,al mov dx,1f2h ;Sector count port mov al,1 ;Write one sector out dx,al mov dx,1f3h ;Sector number port mov al,1 ;Wrote to sector one out dx,al mov dx,1f4h ;Cylinder low port mov al,0 ;Cylinder 0 out dx,al mov dx,1f5h ;Cylinder high port mov al,0 ;The rest of the cylinder 0 out dx,al mov dx,1f7h ;Command port mov al,30h ;Write with retry. out dx,al oogle: in al,dx test al,8 ;Wait for sector buffer ready. jz oogle mov cx,512/2 ;One sector /2 mov si,offset buffer mov dx,1f0h ;Data port - data comes in and out of here. rep outsw ;Send it. ; ------------ mov ax,201h ;We'll read in sector 1 using mov bx,offset buffer2 ;int13h and see if we are successful. mov cx,1 mov dx,80h int 13h mov cx,512 mov si,offset buffer mov di,offset buffer2 repe cmpsb ;Compare the buffers. jne failure mov ah,9 mov dx,offset write_msg int 21h jmp w_exit failure: mov ah,9 mov dx,offset fail int 21h w_exit: mov ax,4c00h ;Exit the program int 21h write_msg db 'Sector one written to using the ports, OH NO! there goes XP.$' fail db 'Writing using ports failed.$' buffer db 512 dup ('A') buffer2 db 512 dup ('D') Its the fat16/32 driver thats harder to code. Hope this helps. |
|||
![]() |
|
dosin 27 Feb 2009, 19:18
Thanks Dex..
have you ever tried these? Quote: Its the fat16/32 driver thats harder to code This will not be a problem.. Since it will be based on a new filesystem.. |
|||
![]() |
|
Dex4u 28 Feb 2009, 02:39
Yes in my OS i have two methods to read/write hdd, one go back to realmode for using bios int 13h and the other using the above code.
PS: You can use this simple demo to test it Code: ;************************************ ; By Dex ; Assemble with fasm ; c:\fasm Hdd.asm Hdd.bin ; ;************************************ org 0x7C00 use16 ;**************************** ; Realmode startup code. ;**************************** start: xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,0x7C00 ;***************************** ; Setting up, to enter pmode. ;***************************** cli lgdt [gdtr] mov eax, cr0 or al,0x1 mov cr0,eax jmp 0x10: protected ;***************************** ; Pmode. NOTE: Untested |
|||
![]() |
|
dosin 28 Feb 2009, 03:54
Thanks Dex - I will give a try...
|
|||
![]() |
|
dosin 03 Mar 2009, 19:28
I am currently working on a program that can detect HD drives and return manufacturer info.. using ports.. will be posting a sample boot loader..
for testing soon! ![]() I was able to get all the info off my disks using ports.. and just need time to put it together.. lol once this is done will begin work on detecting usb.. if tests on other PCs go well!! I think this should be the 1st step.. before writing/reading from disk.. |
|||
![]() |
|
edfed 04 Mar 2009, 17:50
i had made my first try with PIO using the example from DEX.
but it don't works. it displays only FFFFFFFF.... i didn't see what is lacking to obtain a real PIO sector read. Last edited by edfed on 08 Mar 2009, 08:40; edited 1 time in total |
|||
![]() |
|
Dex4u 04 Mar 2009, 18:50
The above code as now been tested by a member of my forum as working, so it must be something in your code, eg: your are reading byte at a time after
";Data port-data comes in and out of here" Try reading WORD To see if that helps |
|||
![]() |
|
dosin 04 Mar 2009, 19:14
post removed..
Last edited by dosin on 05 Mar 2009, 22:24; edited 2 times in total |
|||
![]() |
|
edfed 04 Mar 2009, 19:18
no problems.
finally the bug is from win98. i tested the original version in real boot and i saw it was OK. thanks Dex4u after, i tested mine in real boot, and it is ok. i can build a little boot sector reader now. Code: testide dd f.gnode,0,0,320,200,@f-$-4 dd .txt dd .hexa dd .ide @@: .txt dd f.txt,30,30,200,150,100h,.txtbuf,font85 .hexa dd f.hexa,.buf,.buf+512,.txtbuf,.txtbuf+2000,32 .ide dd f.asm,@f @@: push eax ebx ecx edx esi edi mov dx,1f6h ;Drive and head port mov al,0a0h ;Drive 0, head 0 out dx,al mov dx,1f2h ;Sector count port mov al,1 ;Read one sector out dx,al mov dx,1f3h ;Sector number port mov al,1 ;Read sector one out dx,al mov dx,1f4h ;Cylinder low port mov al,0 ;Cylinder 0 out dx,al mov dx,1f5h ;Cylinder high port mov al,0 ;The rest of the cylinder 0 out dx,al mov dx,1f7h ;Command port mov al,20h ;Read with retry. out dx,al @@: in al,dx test al,8 ;This means the sector buffer requires ;servicing. jz @b ;Don't continue until the sector buffer ;is ready. mov ecx,512/2 ;One sector /2 mov edi,.buf mov dx,1f0h ;Data port - data comes in and out of here. push es cs pop es rep insw pop es pop edi esi edx ecx ebx eax ret .buf rb 512 .bufend db 0 .txtbuf rb 2000 .txtbufend db 0 Last edited by edfed on 08 Mar 2009, 08:32; edited 3 times in total |
|||
![]() |
|
dosin 04 Mar 2009, 19:22
nice! Glad to hear you have it working!
|
|||
![]() |
|
dosin 19 May 2009, 03:25
I am making a HD Multi boot loader.. and utils installer ect...
Is there any features that anyone here would say is a must have: right now: it has a boot screen that displays any avil portions.. the portions are named at install.. example: 1. Win XP but the string can be up to 15 letters.. and sets a default portion that is done also at install.. and has a timer that will boot it after 15 seconds enless keypress.. if keypress - select a portion to boot 1-4.. ect.. So far testing has been on an XP sys.. all good! will test vista also.. I am looking into linux... but anything that someone would want added .. let me know.. I will give it a try... or any options that would prove helpful please let me know! Thanks in advance... |
|||
![]() |
|
edfed 19 May 2009, 21:28
a hidden multiboot page.
if a win key (or else) is pressed before or during bios boot, the menu appears, else, it boots directly the default os. improve the speed of boot. |
|||
![]() |
|
dosin 19 May 2009, 22:26
Good to see your still around! I saw a post that you were going away for a while!
Quote: a hidden multiboot page. Thats a good idea.. it would cut down on the code also.. I will modify once its finished - tested! so a 2-3 sec delay waiting for win key or something.. instead of 15 secs.. I think it would be best to leave as any key press that way no one would have to remember what key to hit and could hit anything.. I will test to find the right amount of time for delay.. if to fast could become a pain.. |
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.