If you looked at my screenshots, I'm able to access directories from the shell, however, I kind of 'cheated.' I just store virtual memory that is read from, it isn't actually on the disk. I'm wondering how we can write files to the disk, and read files from the disk. Basically the concept of how to implement such feature?
I was thinking about having a directory "conts" in my ISO file that formats the drive and sets the entire drive to the format of "conts." Would that be practical?
Thanks!
Writing / Reading from hd0, etc
Writing / Reading from hd0, etc
There's no place like 127.0.0.1.
- BastetFurry
- Posts: 4
- Joined: Sun Nov 01, 2009 4:36 pm
Re: Writing / Reading from hd0, etc
In my Z80 Thingy i will have some kernel routines accessing the SD card and stepping trough the FAT for the caller app.
So when i have a filemanager app i only need to get the cluster of the root dir trough function GetRootDirCluster
and pass that to WriteClusterToMemory.
When i want to write something i call GetFirstFreeCluster which returns an unused (0x00000000) cluster, call WriteMemToCluster with the cluster, the starting address i want to write and how much i want to write. When i need to write more than 512 byte i just call GetNextFreeCluster and WriteFollowCluster with the new and old cluster number. At the end i just call CloseClusterchain which writes 0x0fffffff into the last cluster.
Get yourself the FAT specs and try to read a file from a FAT media, if you get the hang of it its a walk in the park implementing it. My problem will be implementing 32 bit stuff on an 8 bit CPU, but thats just a hill in said park and no wall...
BTW: If you search trough the microcontroller world there are some nice FAT implementations to learn from.
Its German and for the AVR using gcc-avr, but you might be able to make something out of it: http://www.mikrocontroller.net/articles/AVR_FAT32
So when i have a filemanager app i only need to get the cluster of the root dir trough function GetRootDirCluster
and pass that to WriteClusterToMemory.
When i want to write something i call GetFirstFreeCluster which returns an unused (0x00000000) cluster, call WriteMemToCluster with the cluster, the starting address i want to write and how much i want to write. When i need to write more than 512 byte i just call GetNextFreeCluster and WriteFollowCluster with the new and old cluster number. At the end i just call CloseClusterchain which writes 0x0fffffff into the last cluster.
Get yourself the FAT specs and try to read a file from a FAT media, if you get the hang of it its a walk in the park implementing it. My problem will be implementing 32 bit stuff on an 8 bit CPU, but thats just a hill in said park and no wall...
BTW: If you search trough the microcontroller world there are some nice FAT implementations to learn from.
Its German and for the AVR using gcc-avr, but you might be able to make something out of it: http://www.mikrocontroller.net/articles/AVR_FAT32
Re: Writing / Reading from hd0, etc
Also see this http://forum.osdev.org/viewtopic.php?t= ... hdd#p85105
And then as BastetFurry said read about how fat works.
And then as BastetFurry said read about how fat works.
Re: Writing / Reading from hd0, etc
Thanks for the replies! I'm wanting to write / read to 1f0?
Basically, does it work similar to this?
Broken into sectors that can be divided by data and organized by a 'divider' (/) of the sorts? Am I wanting to write to 1f0?
Basically, does it work similar to this?
Broken into sectors that can be divided by data and organized by a 'divider' (/) of the sorts? Am I wanting to write to 1f0?
There's no place like 127.0.0.1.
-
- Member
- Posts: 50
- Joined: Sat Mar 21, 2009 9:42 pm
Re: Writing / Reading from hd0, etc
@blah569
in real mode you can use 0x13h bios.
in protected mode you have to program the ATA controller.
@BastetFurry
isnt programming an 8 bit processor a bit too 1980s?
in real mode you can use 0x13h bios.
in protected mode you have to program the ATA controller.
@BastetFurry
isnt programming an 8 bit processor a bit too 1980s?
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: Writing / Reading from hd0, etc
You can, but don't have to.smeezekitty wrote:@blah569
in real mode you can use 0x13h bios.
A lot of embedded devices still use 8-bit processors, including the Z80 or the i8051/i8052.. my USB 2.0 disk enclosure has one.smeezekitty wrote:@BastetFurry
isnt programming an 8 bit processor a bit too 1980s?
There is nothing wrong with expanding ones knowledge of other architectures and programming within new constraints.
Please think before posting, the 1980's gave us BSD and The Smurf's.
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Writing / Reading from hd0, etc
Also, the TI-83+ series calculators (including the current TI-84+) uses the z80 processor, so there are many z80 assembly programmers still out there today.
IIRC the TI-82, TI-83, TI-83+, TI-83+ SE, TI-84+, TI-84+ SE, and TI-85 calculators all use the z80. The TI-89 series, as well as a couple others that I can't remember right now, all use the Motorola 68K.
I'm sure there are many other still-manufactured products that use the z80, since you can still buy them from the manufacturer.
IIRC the TI-82, TI-83, TI-83+, TI-83+ SE, TI-84+, TI-84+ SE, and TI-85 calculators all use the z80. The TI-89 series, as well as a couple others that I can't remember right now, all use the Motorola 68K.
I'm sure there are many other still-manufactured products that use the z80, since you can still buy them from the manufacturer.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Writing / Reading from hd0, etc
Thanks for the replies! However, in using real mode, how would you go about querying the BIOS to find all active medias? (If querying the BIOS is needed). What would basically be the logic to send a query to the BIOS (or whatever else) to return a list of all active medias present?
For the concept of formatting, you would basically write 0x0 to all sectors on the drive following the guidelines for the desired file system?
For the concept of formatting, you would basically write 0x0 to all sectors on the drive following the guidelines for the desired file system?
There's no place like 127.0.0.1.