Shutdown and return to real mode #97
macpacheco
started this conversation in
Show and tell
Replies: 1 comment
-
ACPI is going to be the necessary evil here as we want something that works on UEFI and BIOS-booted systems. Pure64 already pulls some data from the ACPI tables. I'll extend it to check for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I wanted to implement CTRL-ALT-DEL for reboot and CTRL-ALT-SHIFT-DEL for shutdown, straight in the keyboard interrupt.
Reboot is easy peasy.
Shutdown is a pain. I didn't want to do ACPI table parsing so the only generic way was a return to real mode to call APM.
Took me days to figure it out.
1 - Save the real mode IDT from 0x0 to the last bytes of real mode memory (must do it soon enough otherwise it gets wiped out even before long mode gates are built):
Pure64/src/pure64.asm:
2 - Create 16 bit code and data segments in gdt64, 32 bit protected mode segments were created, but unused:
Pure64/sys/sysvar.asm
3 - Shutdown code per se:
Ok, this won't work for UEFI boot. But I couldn't find the explanation anywhere on how to the return to real mode from long mode. Recipes I found wanted to drop from long to protected mode then to real, without 16 bit segments, qemu definitely didn't like this. Instead of just changing the bits that were necessary in CR3 and EFER, I copied the original values when boot sector is executed, seemed safer.
If I could ask to keep the original interrupt vectors untouched and build new ones somewhere else, it would be great. I couldn't figure out a safe location to do so. Point it out that safe location and I'll do it.
Beta Was this translation helpful? Give feedback.
All reactions