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++
219 views Asked by IlcIliaDev At
1
There are 1 answers
Related Questions in C
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in FILESYSTEMS
- Where exactly is the first data sector on a FAT file system?
- `df` command not capturing entire output in perl
- Is it possible to mount a logical volume without wiping the data?
- Speed up search of remote directories
- How to change the directory file system without losing files?
- Flutter SDK: Files Deleted Automatically (e.g., dart.exe), Errors in Android Studio
- How to store metadata for a UTF-8 text file cross-platform?
- fsck error on boot: dev/mapper/ubuntu--vg-ubuntu--lv: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY
- rouble with mounting Python code to FUSE: No response and prolonged processing ---
- mkfs.erofs erofs: failed to lookup selabel
- How to deny user access MacFuse file system by the really path
- Is it faster to read a file on an NVMe using threads?
- list folders containing mp3 files using the Capacitor Filesystem
- How to use xdg-open in bwrap environment to open dir in the unsandboxed filesystem
- How to provide content of (locally) encrypted files to the iOS and macOS system
Related Questions in OSDEV
- Seeking for the the method for adding the DL (data register) value to DX register
- "Config.guess failed to determine the host type" when trying build binutils-2.7 with Cygwin
- LLVM code generation causes problems with pointer arithmetic
- Maximum CPU Voltage reading
- Purpose of stack register(s) in holding 0x7c00
- Behavior of the adress 0x7e00 in different sectors and their alternatives
- General Protection Fault encountered when executing SYSRET
- Bootloader are really in sector 0?
- Is heap memory in Linux contiguous?
- How to define different [global_allocator]s for a monolithic os kernel and its applications
- QEMU: address of grub module has zeros if not referenced directly in the code
- Assembly draw line function
- "Cannot find bounds of current function" error in GDB while debugging bootloader code
- Confusion regarding CS and DS segment registers during bootloading process
- Rust tell the compiler to not trust the registers?
Related Questions in UEFI
- Direct boot from USB without changing BIOS setting or selecting from boot manager
- Passing 'unsigned short[8]' to parameter of type 'CHAR16 *' (aka 'short *') converts between pointers to integer types with different sign
- UEFI Event Logs
- Patching UEFI Pei module problems with addresses
- Can DUET be run on a computer already has UEFI?
- Syslinux EFI 64bit: start_image() returned Load Error
- Calculate time taken by program to run in uefi
- Creating LVM Partitions for Web App, Database, Unused Space, and Swap on Almalinux 9.3
- UEFI Application for pci link test
- UEFI how to add user
- Is it possible to automate/script MOK (Machine Owner Key) enrollment in RHEL 8 VMware machine?
- How do I get a Unique Partition GUID from a device path in gnu-efi?
- Why is load image returning EFI_NOT_FOUND?
- Is it possible for kernel mode driver to interact with user at system boot?
- Why won't my hello world EFI program build correctly?
Related Questions in GUID-PARTITION-TABLE
- when I try to enable flash encryption in esp32, the bootloader size is large . But I'm unable to find bootloader field in partition table
- Replica table partition in EDB PostgreSQL
- booting google coral dev board from sd card
- Partition tables esp32 3mb no ota 1mb spiffs Platform io
- GPT FileSystem after exiting boot services in C/C++
- 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
- Get Volume Guid of EFI partition on Windows 2012 R2
- What virtual disk formats are comptatible with GPT?
- How is the partition type GUID supposed to be interpreted?
- New dynamic volume (loop) missed after restart centos
- How to find if disk is GPT using python on Windows?
- Legacy MBR - what's between offsets 424 and 440?
- How does the Boot Indicator field fit inside the MBR partition table?
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?
Popular Tags
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)
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.