diff --git a/0F_executionlevel/OLVASSEL.md b/0F_executionlevel/OLVASSEL.md index be8534b6..cddb1f2b 100644 --- a/0F_executionlevel/OLVASSEL.md +++ b/0F_executionlevel/OLVASSEL.md @@ -13,15 +13,16 @@ Exception return from AArch64 EL2 to AArch64 EL1 PC 0x8004c Current EL is: 00000001 ``` -FIGYELEM: a teljesség kedvéért hozzáadtam az EL3-at is az [Issue #6](https://github.com/bztsrc/raspi3-tutorial/issues/6) -miatt, bár semmilyen módon nem tudtam kipróbálni. - Start ----- Hozzáadtam egy pár Assembly sort, ami átállítja a futási szintet, ha nem rendszerfelügyeleti szinten lennénk. De mielőtt ezt megtehetnénk, hozzáférést kell biztosítani a számláló regiszterekhez (counter, amit a wait_msec() -használ). Végezetül egy kivételkezelőből való visszatérést hazudunk, hogy ténylegesen szintet váltsunk. +használ), valamint megmondjuk a CPU-nak, hogy AArch64 módban fut az EL1. Végezetül egy kivételkezelőből való +visszatérést hazudunk, hogy ténylegesen szintet váltsunk. + +FIGYELEM: a teljesség kedvéért hozzáadtam az EL3-at is az [Issue #6](https://github.com/bztsrc/raspi3-tutorial/issues/6) +miatt, bár normális körülmények között a Raspberry EL2-n futtatja a kernel8.img-t. Main ---- diff --git a/0F_executionlevel/README.md b/0F_executionlevel/README.md index e319fcb0..4087e944 100644 --- a/0F_executionlevel/README.md +++ b/0F_executionlevel/README.md @@ -12,15 +12,15 @@ Exception return from AArch64 EL2 to AArch64 EL1 PC 0x8004c Current EL is: 00000001 ``` -NOTE: For completeness, I've added code for EL3 too because of [Issue #6](https://github.com/bztsrc/raspi3-tutorial/issues/6), -although I had no means to test it. - Start ----- I've added a little bit more Assembly code for changing the execution level if we're not at supervisor level. -But before we can do that, we have to grant access for the counter registers (used by wait_msec()). -Finally, we fake an exception return to change the level for real. +But before we can do that, we have to grant access for the counter registers (used by wait_msec()), and tell +the CPU we want AArch64 mode in EL1. Finally, we fake an exception return to change the level for real. + +NOTE: For completeness, I've added code for EL3 too because of [Issue #6](https://github.com/bztsrc/raspi3-tutorial/issues/6), +although normally Raspberry runs kernel8.img in EL2. Main ---- diff --git a/0F_executionlevel/kernel8.img b/0F_executionlevel/kernel8.img index 6f694389..4d7db475 100755 Binary files a/0F_executionlevel/kernel8.img and b/0F_executionlevel/kernel8.img differ diff --git a/0F_executionlevel/start.S b/0F_executionlevel/start.S index 33b5f4f9..8ebc2195 100644 --- a/0F_executionlevel/start.S +++ b/0F_executionlevel/start.S @@ -60,6 +60,11 @@ _start: 5: cmp x0, #4 beq 5f msr sp_el1, x1 + // enable AArch64 in EL1 + mov x0, #(1 << 31) // AArch64 + orr x0, x0, #(1 << 1) // SWIO hardwired on Pi3 + msr hcr_el2, x0 + mrs x0, hcr_el2 // enable CNTP for EL1 mrs x0, cnthctl_el2 orr x0, x0, #3 diff --git a/10_virtualmemory/start.S b/10_virtualmemory/start.S index 6e757440..a7cff2da 100644 --- a/10_virtualmemory/start.S +++ b/10_virtualmemory/start.S @@ -65,11 +65,12 @@ _start: orr x0, x0, #3 msr cnthctl_el2, x0 msr cntvoff_el2, xzr - // Setup SCTLR access + // enable AArch64 in EL1 mov x0, #(1 << 31) // AArch64 orr x0, x0, #(1 << 1) // SWIO hardwired on Pi3 msr hcr_el2, x0 mrs x0, hcr_el2 + // Setup SCTLR access mov x2, #0x0800 movk x2, #0x30d0, lsl #16 msr sctlr_el1, x2 diff --git a/11_exceptions/start.S b/11_exceptions/start.S index f940f0c8..302ba1ac 100644 --- a/11_exceptions/start.S +++ b/11_exceptions/start.S @@ -65,11 +65,12 @@ _start: orr x0, x0, #3 msr cnthctl_el2, x0 msr cntvoff_el2, xzr - // Setup SCTLR access + // enable AArch64 in EL1 mov x0, #(1 << 31) // AArch64 orr x0, x0, #(1 << 1) // SWIO hardwired on Pi3 msr hcr_el2, x0 mrs x0, hcr_el2 + // Setup SCTLR access mov x2, #0x0800 movk x2, #0x30d0, lsl #16 msr sctlr_el1, x2