Parsing info from bootloader in rust kernel

Поділитися
Вставка
  • Опубліковано 3 жов 2024

КОМЕНТАРІ • 13

  • @m4rt_
    @m4rt_ 11 місяців тому +3

    btw, on Linux syscalls pass arguments using
    rax (syscall), rdi (arg 0), rsi (arg 1), rdx, (arg 2), r10 (arg 3), r8 (arg 4), r9 (arg 5)
    chromiumos has some good documentation on Linux syscalls.

  • @Bobbias
    @Bobbias 11 місяців тому +2

    21:40 "I don't know what E stands for" referring to the prefix on the 32 bit x86 register names. I always assumed it stood for "extended", since they were quite literally just an extension of the original 16 bit registers.

  • @m4rt_
    @m4rt_ 11 місяців тому +1

    I think the pages and fragmentation thing is correct.
    The solution I have seen is something called virtual memory.

  • @m4rt_
    @m4rt_ 11 місяців тому +1

    it's better to do
    int *x = (int*) malloc(sizeof(int));
    since the size of int may change depending on your compiler

  • @m4rt_
    @m4rt_ 11 місяців тому +1

    iirc the e in esp is because it's 32 bit
    if it was 64 bit it would be rsp
    so if you were in 64 bit esp would be the lower half of the rsp register

    • @sphaerophoria
      @sphaerophoria  11 місяців тому +2

      AFAICT (without actually looking it up), this is right. There's also 8/16 byte versions (ax, dax, eax, rax) IIRC

    • @Bobbias
      @Bobbias 11 місяців тому +2

      @@sphaerophoria Yes. rax = 64 bit, eax = 32 bit, ax = 16 bit, ah/al = 8 bit high and low bytes, respectively.

  • @m4rt_
    @m4rt_ 11 місяців тому +1

    it took me embarrassingly long to realize that boot_loader_name is an address to a c string and not 8 chars packed into a u32... the multiboot info stuff was annoying to add (I've been working on my own implementation while watching).

  • @m4rt_
    @m4rt_ 11 місяців тому +1

    you can do
    char *x = malloc(5); (you need an exta one because it's null terminated)
    strncpy(x, "Hello", 5); (avoids buffer overflow because you only copy 5 chars)
    printf("%s
    ", x); (printing it)
    free(x); (freeing the memory)

  • @atrocitus777
    @atrocitus777 11 місяців тому +1

    do you still need to use rust nightly on bare metal like this? i remember reading a blog post back in the day where you had to be on the nightly version.

    • @sphaerophoria
      @sphaerophoria  11 місяців тому +1

      I'm definitely on nightly. I thought I have to be, but you have me second guessing myself. I set up a quick test, and I'm honestly not sure. I'm having trouble defining the custom target as the standard libraries aren't build by default. Apparently the feature to build-std is unstable (nightly) only (cargo -Z build-std)
      It seems like it might be doable, it's possible to make a no-std executable with stable rust, but I'm not sure if I could get as far as easily.

    • @atrocitus777
      @atrocitus777 11 місяців тому +1

      ok i only have the stable release version on my mac but i guess that makes sense then that you would need to use the nighly version. thanks. @@sphaerophoria

    • @sphaerophoria
      @sphaerophoria  11 місяців тому +2

      I think it's pretty easy if you've installed via rustup to just override to nightly for a single project. `cargo +nightly build` or `rustup override set nightly` or something