diff --git a/14_raspbootin64/OLVASSEL.md b/14_raspbootin64/OLVASSEL.md index 4ae239fc..0820ac6d 100644 --- a/14_raspbootin64/OLVASSEL.md +++ b/14_raspbootin64/OLVASSEL.md @@ -16,11 +16,11 @@ Hogy ezt megvalósítsuk, egy alacsonyabb címre linkeljük a kódot, és mivel nekünk kell a módosított címre másolnunk magunkat. Fontos, hogy ezalatt csak relatív címzést használhatunk. Amikor végeztünk, a 0x80000-as címen lévő memóriának használaton kívülinek kell lennie. Ajánlott a kódunkat minimalizálni, mivel úgyis figyelmen kívül hagyja az újonnan betöltendő kód. Ezért kivettem az `uart_puts()` eljárást, így a teljes méret -1024 bájt alá csökkent. Ezt a következő paranccsal ellenőriztem: +1024 bájt alá csökkent. Ezt a következő paranccsal ellenőrizheted: ```sh $ aarch64-elf-readelf -s kernel8.elf | grep __bss_end - 21: 000000000007ffd0 0 NOTYPE GLOBAL DEFAULT 4 __bss_end + 21: 000000000007ffc0 0 NOTYPE GLOBAL DEFAULT 4 __bss_end ``` Start diff --git a/14_raspbootin64/README.md b/14_raspbootin64/README.md index 48a43147..8d4c3e31 100644 --- a/14_raspbootin64/README.md +++ b/14_raspbootin64/README.md @@ -13,14 +13,14 @@ If you want to send kernels from a Windows machine, I suggest to take a look at In order to load the new kernel to the same address, we have to move ourself out of the way. It's called chain loading: one code loads the next code to the same position in memory, therefore the latter thinks it was loaded by the firmware. To implement that we use a different linking address this time, and since GPU loads us to 0x80000 -regardless, we have to copy our code to that link address. That's important that we can only use relative addresses +regardless, we have to copy our code to that link address. What's important, that we can only use relative addresses while doing so. When we're done, the memory at 0x80000 must be free to use. We also should minimize the size of the loader, since it will be regarded by the newly loaded code anyway. By removing `uart_puts()` I've managed to shrink the -size below 1024 bytes. I've checked that with: +size below 1024 bytes. You can checked that with: ```sh $ aarch64-elf-readelf -s kernel8.elf | grep __bss_end - 21: 000000000007ffd0 0 NOTYPE GLOBAL DEFAULT 4 __bss_end + 21: 000000000007ffc0 0 NOTYPE GLOBAL DEFAULT 4 __bss_end ``` Start diff --git a/14_raspbootin64/kernel8.img b/14_raspbootin64/kernel8.img index 0c1a13b1..7551a233 100755 Binary files a/14_raspbootin64/kernel8.img and b/14_raspbootin64/kernel8.img differ diff --git a/14_raspbootin64/main.c b/14_raspbootin64/main.c index ec4acb38..cc6302b3 100644 --- a/14_raspbootin64/main.c +++ b/14_raspbootin64/main.c @@ -25,13 +25,10 @@ #include "uart.h" -// import our start address from linker -extern char _start; - void main() { int size=0; - char *kernel=(char*)&_start; + char *kernel=(char*)0x80000; // set up serial console uart_init();