I am creating an operating system and have strugled to find a way to implement a filesystem into it for the past several months. I can read files in boot services but after exiting boot services in UEFI the function can't read the file. I am trying to create a filesystem driver outside boot services using GPT (though if possible MBR but based on what I've seen near impossible). All source code and examples I've seen use multiboot with GRUB but I do not use the GRUB bootloader. Instead I followed the one from Poncho's OSDev 2 series. I have seen an example from WYOOS where he uses the MSDos partition system but it depends on multiboot therefore it doesn't work in my scenario. All help will be appreciated. Thanks.
GPT FileSystem after exiting boot services in C/C++
218 Views Asked by IlcIliaDev At
1
There are 1 best solutions below
Related Questions in C
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in FILESYSTEMS
- What kernel level functions are called when we perform write in ext3 file system?
- How to save a file to desired location in c++?
- MongoDB over Traditional File Based System
- How to reliably detect that an atomic move of a directory failed because the target already exists
- Meteor - Create a new folder in the public directory on account creation
- Storing images in MSSQL vs Disk
- Why segment files into chunks for HTTP streaming?
- Difference between stdout and /dev/stdout
- find and remove all closed files that are not modified in some-time
- TypeScript + Node.js FileSystem issue
- Scan folders with non English letters in a given directory
- unknown field 'ioctl' specified in initializer
- how can i encrypt every file with a different key using encFS
- How is a file loaded in the FAT file system?
- Ext.device.filesystem.FileEntry.read() - type: "text" returns blank file
Related Questions in OSDEV
- Rustc/LLVM generates faulty code for aarch64 with opt-level=0
- MinGW's ld cannot perform PE operations on non PE output file
- GCC 5.1.0-4 cross compiler build fail
- Link object files from header files in real mode when using GCC -m16 option?
- Constant reboot after setting up the Global Descriptor Table and protected mode
- Can't load flat binary file into kernel
- Linear addressing and the GDT
- How do you find the PCI memory hole on x86?
- Extended ASCII characters are printed in yellow instead of white - OSDev
- The Kernel starts behaving abnormally when the kernel code gets a little bigger
- LD errors while linking 16-bit real mode code into a Multiboot compliant ELF executable
- How can I provide a reliable callback functionality?
- Can HDD emulation be used to allow me to use my own bootable file system on a CD?
- Is it bad that a process should self create an own stack?
- OS development - converting logical block format to Cylinder-Head-Sector
Related Questions in UEFI
- board firmware update through uefi capsule feature from Linux
- How to static link EDK II library into application in Visual Studio 2008 tool chain
- uEFI Virtual to Physical Memory translation
- Can't format Hard Disk Drives and install linux to Dell hybrid ultrabook
- Failed to add external hard disk with FreeBSD 10.1
- How to remove Ubuntu entries from UEFI
- Use of redefining void pointer to pointer to an anonymous structure?
- UEFI Secure Boot Linux Permissions
- Reading/Writing EFI variables on Linux in kernel mode
- How does an OS find a peripheral's assigned address(es)?
- UEFI secure boot issues with hello efi
- How does UEFI do task scheduling
- Is it possible to use EFI to create fully cross-platform disk driver?
- Are Intel's PTT and TPM equivalent
- Efi app linker error unresolved external symbol gEfiShellProtocolGuid referenced in function main
Related Questions in GUID-PARTITION-TABLE
- Partition tables esp32 3mb no ota 1mb spiffs Platform io
- Problems with cloud-init to use gpt instead mbr
- In GUID Partition Table how can I know how many partitions there are?
- In linux, fsck gpt external hard disk fail
- How does the GRUB 2 UEFI loader know where to look for the configuration file (or where the 2nd stage's files are located)?
- Confusion about GUID Partition Table specification
- How is data stored on disk? - EFI GUID
- Erased all partitions and the partition table on the external hard disc
- What virtual disk formats are comptatible with GPT?
- How is the partition type GUID supposed to be interpreted?
- Virtualbox fail to bootup guest from GPT physical partition
- GPT FileSystem after exiting boot services in C/C++
- How to partition table on Yii2?
- Legacy MBR - what's between offsets 424 and 440?
- Get Volume Guid of EFI partition on Windows 2012 R2
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You don't give much information in the question but I assume you want an hard-drive driver that will be able to read files from drives on a filesystem. In the end, you don't really implement a filesystem driver. You implement an hard-drive driver that will be able to read/write an hard-drive. The filesystem logic comes on top of that driver.
Below that, you want an ACPI interpreter and a PCI subsystem that will manage PCI devices. It is really complex and isn't just like calling a function that gets the job done. Once you got a PCI subsystem along with an ACPI interpreter and a filesystem driver, you got quite an advanced OS. This isn't going to be one function call. It requires planning and reading specifications.
With that said, I am currently writing an x86-64 OS myself and what I'm planning to do might be of interest (or not). From UEFI, I use the following to load my kernel from disk:
I load a file called startup.elf that will set up a high-half mapping of virtual memory for the kernel. Then I allocate lots of pages (4096) for the kernel which is much smaller than this. The startup.elf executable is then getting the address of the first byte of the kernel from a fixed address and mapping the kernel's loadable segments starting at 0x400000 in physical memory. The upper 2GB of the virtual address space is thus mapped from 0x0 to 2GB in physical memory. The kernel's location in virtual memory is thus 0xffff_ffff_8040_0000. This is where I jump to from the startup.elf file. There are probably several ways to do that but I prefer to have 2 separate files for my kernel (the startup executable and the kernel's executable).
From there, what I am planning to do is to implement a memory management subsystem. Memory management is the first thing you want to implement because every other subsystem is using memory. You want to be able to allocate memory for the kernel's needs.
Afterwards, I plan on implementing an ACPI subsystem that will parse all ACPI tables and interpret the AML language that will allow to gather information on what is present on the motherboard that I need to drive. To do that, I get the RSDP from UEFI and I find the other tables from the RSDP (see https://wiki.osdev.org/RSDP). The ACPI tables allow to gather all information about the hardware on your computer. For example, the MCFG tells you where the configuration space of PCI devices will start (see https://wiki.osdev.org/PCI).
On top of ACPI, I am planning to implement a PCI subsystem that will allow some kind of generic interface to read and write PCI registers and some kind of generic interrupt number allocator. PCI mostly works with MSI/MSI-X today. I am planning to forget about everything that is legacy and just work with the most modern stuff and just assume the presence of all this hardware (that is present on 99% of desktop x64 computers today). Windows does the same with their most recent requirements. They simply give some basic requirements for running their operating-system and the rest isn't supported. This is unlike the Linux kernel which attempts to support everything down to very old dinosaur computers. This makes the code very bloated and not very useful most of the time.
The PCI subsystem will be used by the AHCI driver to manage hard-disks. The AHCI is a PCI device which triggers interrupts using MSI (see https://www.intel.ca/content/www/ca/en/io/serial-ata/serial-ata-ahci-spec-rev1-3-1.html). UEFI firmware comes with an AHCI driver. This is why it manages to write/read hard-drives.
You see that a lot has to be done before you can actually start loading stuff from the hard-drive. You'd need to write a memory management scheme, interpret AML and ACPI tables, parse the PCI buses to find the devices and their configuration spaces and finally write an AHCI driver. Even then, you are probably not finished because modern SATA SSDs have very high throughput. They thus load and store data in the several MBs at once. You'd need some kind of efficient algorithm to cache some portions of the hard-disk and make sure to not load/store all the time as it takes a lot of RAM space. For an older hard-disk, it is going to be easier but not easy.