i have implemented putch() , getchar() and other elemnetary functions in c [without the header files] now i want to perform read operations on a text file before loading the kernel ...... i am utterly confused in implemneting file i/o functions??? please help
i can read a fat filesystem
reading a text file
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
I think he wants an fread() implemented on top of get_512_bytes()...
If you keep 512 bytes reserved for temporary storage that is just as simple as copying the amount of bytes and keeping track of how much is left. If you have eaten up all the 512 bytes, you load the next set and copy whatever you still need to do.
Nothing interesting really...
If you keep 512 bytes reserved for temporary storage that is just as simple as copying the amount of bytes and keeping track of how much is left. If you have eaten up all the 512 bytes, you load the next set and copy whatever you still need to do.
Nothing interesting really...
after i have loaded the second stage bootloader in the memory i want to display the contents of a text file which contains the names and the paths of the various kernels present on the disk in the form of a list so that the user can select his kernel from the list..but i am helpless as to how to read the file ???
getch() / putch() won't help you there. You need, in your second stage, logic for accessing an arbitrary sector on disk, logic for interpreting the file system (i.e., where to find the directory, how to search the directory for a given file name, and how to determine first / subsequent sectors of the file once you've found it), and then reading the sectors of the file at the appropriate memory locations.
Basically, you need a rudimentary disk / file system driver in your second stage.
Basically, you need a rudimentary disk / file system driver in your second stage.
Every good solution is obvious once you've found it.
I wouldn't implement this list as a file as it will require support for a FS to be already implemented on your second stage. What I would do is store the "data" of the list at a predefined place on your boot image and read it using basic disk IO operations into memory. Then handling it in whatever way you'd like.