fix: plug memory map leak, save sp_el0, dynamic UART, kill loop

- Bootloader: reallocate memory map buffer when ExitBootServices fails,
  so GetMemoryMap doesn't scribble past the old allocation on retry.
- vectors.S: actually store sp_el0 into the exception frame. Previously
  it was read into x24 and then… vanished. EL0 tasks would wake up with
  a corrupted stack pointer. Not great.
- Serial: split hardcoded 0x09000000 into a fallback default; add
  SerialUpdate() so the DTB-parsed UART address actually gets used.
- DTB: add bounds check on reserved[] with PMM's 3 extra slots accounted
  for, so malformed/overstuffed DTBs don't silently corrupt memory.
- PMM.h: bump kVMMaxReservedRegions 128→256, define kPMMReservedRegionCount.
- Types.h: remove `#define loop while(1)`. while(true) is fine.
- Rename IOSerial* → Serial* — the IO prefix was redundant, Serial.c
  already lives under IO/.
This commit is contained in:
karina
2026-05-03 00:32:30 +04:00
parent 7ff9f4ad4c
commit 6dd68f8162
11 changed files with 47 additions and 28 deletions
+4 -4
View File
@@ -85,11 +85,11 @@ Address SchedulerNext(Address stackPointer) {
if (taskIterator->sleepTicks > 0) taskIterator->sleepTicks--;
taskIterator = taskIterator->next;
} while (taskIterator != gOSSchedulerCurrentTask->next);
if (gOSSchedulerCurrentTask->sleepTicks > 0) gOSSchedulerCurrentTask->sleepTicks--;
OSTask* nextTask = gOSSchedulerCurrentTask->next;
loop {
while (true) {
if (nextTask->state == OSTaskStateDead) {
nextTask = nextTask->next;
if (nextTask == gOSSchedulerCurrentTask) OSPanic("No running tasks");
@@ -110,7 +110,7 @@ Address SchedulerNext(Address stackPointer) {
CPUSwitchAddressSpace(physicalL0Table);
}
gOSSchedulerCurrentTask = nextTask;
return gOSSchedulerCurrentTask->stackPointer;
}
@@ -118,4 +118,4 @@ void SchedulerYield(UInt64 ticks) {
gOSSchedulerCurrentTask->sleepTicks = ticks;
gOSSchedulerCurrentTask->state = OSTaskStateSleeping;
CPUException(kOSSchedulerExceptionNumber);
}
}