Get Memory Map & Exit Boot Services | UEFI Dev (in C)

Поділитися
Вставка
  • Опубліковано 3 лип 2024
  • Getting a memory map and officially exiting boot services, which means full control over all memory and the machine from that point on e.g. you can load your OS!
    Errata:
    - Fixed the error message for the initial GetMemoryMap() call after this video.
    - While there can be reserved space for firmware and micro controllers, etc. on other devices like SSDs, it's probably more common that a storage device's advertized amount is in base 10, and the actual reported amount is in base 2. Like 1024 vs 1000 for KiB vs KB.
    - I did move functions into efi_lib.h, which is included in kernel.c, so most likely that is why it "broke" for me and I had to add a linker script for flat binary kernels. Because those functions would be linked to the start of the binary object before the entry point code. Maybe separate .h/.c files for headers and implementations would've fixed that, or otherwise being a better programmer :^)
    Also, an array ("map") of index to color would be better than a function for getting a number, but that was mainly to show the linking errors that would come up later anyway.
    Links:
    uefi.org/specifications (uefi & other specifications)
    wiki.osdev.org/Paging
    UEFI Programming playlist:
    • UEFI Programming in C
    Git Repo:
    github.com/queso-fuego/uefi-dev
    Repo state at the start of this video:
    git clone --recurse-submodules github.com/queso-fuego/uefi-dev
    cd uefi-dev
    git checkout 85f254359dd78d77ec751366fbb022aeca7bdb55
    Repo state at the end of this video:
    git checkout 74496ccf10bd6ee57d54af322475fd4d8942b881
    Shoutout to ThatOSDev / @thatosdev
    for EFI help, efi_lib.h file and suggestions, and conversation.
    Join the Community Discord: / discord
    Contact:
    queso_fuego.srht.site/contact.html
    If you feel like throwing money my way:
    queso_fuego.srht.site/support.html
    Questions about setup/software/etc.?
    Check the FAQ: queso_fuego.srht.site/about.html
    Next video:
    - Thinking about how to show disks or partitions to the user for an installer option, to write the disk image & bootloader to another disk (or only a partition), so the user can then reboot and run the loaded kernel or an OS on another drive or machine.
    Misc notes:
    - Tried manual camera settings this time for the sony zv1, so it should have the same levels throughout now and not get brighter/darker every few seconds as usual.
    ISO 2000 and F 1/60 (shutter speed) works fine with the lamp on, with white balance set to "fluor.: warm white" (is that flourescent?). Without the lamp it's very blue.
    Also turned off the color correction filter in OBS as it's not needed with these changes.
    If it's slightly too dark, or too orange at night, can tweak it further.
    0:00:00 intro, get definitions from UEFI spec
    0:11:03 make non-efi header file, add memory map typedefs
    0:14:47 make sure main menu only makes 1 timer event
    0:15:40 add print memory map option and get/print functions
    0:27:53 print memory map
    0:44:32 add memory map to kernel parameters & exit boot services
    0:49:21 tips for flat binary kernel
    0:58:41 more fixes for flat binary (again)
    Music credits:
    [Chiptune] Medieval: Minstrel Dance by RandomMind
    Music: www.chosic.com/free-music/all/
    #uefidev #cprogramming #memorymap
  • Наука та технологія

КОМЕНТАРІ • 20

  • @HichamTamri23
    @HichamTamri23 20 днів тому +1

    Gordon Freeman?!!! What are u doing here??!!

  • @nesdi6653
    @nesdi6653 8 днів тому +1

    awesome I been struggling with UEFI over the past months, it's hard to get your mind around for some reason

    • @QuesoFuego
      @QuesoFuego  6 днів тому

      It is a bit scattered around and not well explained. But it's really just an interface or api definitions for a library/framework, that gets info for various devices or parts of firmware. The implementation of that library is hidden, it's implemented in firmware, but you have documentation for how to talk to it, essentially.

  • @haroldcruz8550
    @haroldcruz8550 2 місяці тому

    What a wonderful find for me. Thank you

  • @ThatOSDev
    @ThatOSDev 2 місяці тому +1

    Hey my friend, glad you are still making videos. 👍

  • @konstantinrebrov675
    @konstantinrebrov675 Місяць тому +1

    Hello sir. I have some questions. How old are you? And how long did it take you to get to such a level of programming skills?

    • @QuesoFuego
      @QuesoFuego  Місяць тому +1

      I'm 29, and it's been about 6-7 years of off and on learning and hobby programming, and having a job using a C-like language (RPG).
      I wouldn't say I have skills, I'm pretty slow with things and it's hard to program on camera and talk and think at the same time, but I do read a lot and try to get several different perspectives or articles on doing any one thing, to be able to understand it.
      Also making and testing a few different versions before making a video on something.
      Lately that includes studying documentation or original sources where available, which can take a awhile to piece together a program or project.
      I'm also pretty stubborn and will keep trying just about every permutation and combination of things until it works, then will remove things until it doesn't work, and try to find a balance between those two.
      Then think about why it works in that configuration, and if it can be improved further with your new knowledge and understanding, and why, and repeat.
      I'd say perseverance and time has helped way more than any knowledge or talent, for what it's worth.

  • @hampus23
    @hampus23 2 місяці тому +3

    1:56 There is a lot of typos in the specification 🤣 Saw that many months ago they haven't fixed it yet 🤔

    • @QuesoFuego
      @QuesoFuego  2 місяці тому +5

      Yeah not sure why no one proof reads it first

  • @benjamindeharo314
    @benjamindeharo314 2 місяці тому +1

    Do you still plan to do an emulator, and if yes which machine will it be ?

    • @QuesoFuego
      @QuesoFuego  2 місяці тому +2

      Yes, some time. Probably an NES or gameboy, or a different 6502 or z80 based machine like C64 or zx spectrum, something like that.

    • @benjamindeharo314
      @benjamindeharo314 2 місяці тому

      @@QuesoFuego That's cool !
      Since you're still hesitating on what machine to emulate, I'd suggest the 8080 space invaders arcade machine, as it is somewhere between the chip8 and the gameboy in terms of complexity.
      But whatever you choose, I'll watch it.

    • @dejavu4379
      @dejavu4379 2 місяці тому +1

      @@QuesoFuego A ZX Spectrum would be cool because the graphics are simple.
      I always find the tutorials about the Gameboy and NES to be overwhelming, and I'm sure that's the case for most people.
      The ZX Spectrum is a nice step after the Chip-8 without being overwhelming.

    • @naturerelaxingmusic4961
      @naturerelaxingmusic4961 Місяць тому +1

      The only video tutorial about space invaders is this one :
      ua-cam.com/video/Oyz4yRvYK0s/v-deo.html
      c#, visual studio, using form and all...eww..
      The way QuesoFuego is doing it (c/sdl) would be much more instructive.

  • @user-nf3jr3wl9v
    @user-nf3jr3wl9v 2 місяці тому

    Hi Queso, I really interested in low level programming. How can I learn C? Can you suggest a book for beginners with no programming experience and also any other books that will help me with learning low level stuff?

    • @QuesoFuego
      @QuesoFuego  2 місяці тому +1

      Learning C would be best done by programming in C, and making projects you are interested in and looking things up when you get stuck or want to know better/different ways of doing something.
      I can't tell you how to learn, only that it takes a lot of time and effort, and only you can know how you learn things.
      There isn't a single place or thing for learning programming with no experience, usually school does that or you find some random thing or website and try out html and js, or python, or scratch, or C, or assembly, or anything else, and want to do something with it like make games, cheats, graphics programs, drivers, reverse engineering, making an OS, etc.
      You search up on the topics that interest you and how to do them, starting could be as simple as writing a text file and compiling it and running the program, or making an index.html page and loading that in the browser, and then you go from there.
      You'd want to learn a given language's syntax and semantics, control flow, data flow, data structures and algorithms, built-ins, libraries, etc. but you only learn these things by writing the language and making things and running them, and debugging and all the other fun stuff that comes with it.
      Maybe the most recommended nowadays for C books is:
      C Programming: A Modern Approach, 2nd Edition
      by K. N. King
      But also the classic C book:
      C Programming Language, 2nd Edition
      by Brian W. Kernighan and Dennis M. Ritchie
      You could use gcc with -std=c89 for that book, but some aspects may not work the same today as they did decades ago.
      For low level in general, ideally you'd know computer organization and architecture, different hardware protocols and communication standards, up through assembly language and the ISA for your given processor, file formats, object and executable formats e.g. ELF vs PE files, and how your OS operates on top of all that and how to interact with it, via syscalls or including system headers, and other means.
      That would make C and any other higher level languages make more intuitive sense, as to what they can translate into and run as (the actual operations that happen are different on the cpu, but that's getting into hardware that you can't change, more so than software that you can change).
      A couple books for bottom up learning or more low level topics would be:
      Code: The Hidden Language of Computer Hardware and Software
      by Charles Petzold
      The Elements of Computing Systems, second edition: Building a Modern Computer from First Principles
      by Noam Nisan, Shimon
      Computer Systems: A Programmer's Perspective
      by Randal Bryant, David
      And also maybe some patterson and hennessy books on computer architecture or organization for a given ISA (x86, arm, risc-v, etc.)
      A couple assembly language books, as extra. These are for x86, but arm & others probably have similar things out there, and their own assemblers like cc65 for 6502 for e.g. nes programming, things like that:
      x64 Assembly Language Step-by-Step: Programming with Linux (Tech Today) 4th Edition
      by Jeff Duntemann
      Modern X86 Assembly Language Programming: Covers X86 64-bit, AVX, AVX2, and AVX-512 3rd ed. Edition
      by Daniel Kusswurm

    • @user-nf3jr3wl9v
      @user-nf3jr3wl9v 2 місяці тому

      Thank you so much, I really appreciate this. I will get started on buying the book for c and start my way from their!@@QuesoFuego