Compare commits

..

2 commits

Author SHA1 Message Date
Imbus
146e7f65ca Halt syscall and userspace util. Mapped qemu power. 2025-01-11 14:50:17 +01:00
Imbus
e94eecd9a1 Better hart startup indicators 2025-01-11 14:49:38 +01:00
5 changed files with 10 additions and 2 deletions

View file

@ -30,10 +30,11 @@ main()
} else {
while(started == 0) {}
__sync_synchronize();
printf("hart %d starting\n", cpuid());
printf("Hart/Core [%d]: Starting\n", cpuid());
kvminithart(); // turn on paging
trapinithart(); // install kernel trap vector
plicinithart(); // ask PLIC for device interrupts
printf("Hart/Core [%d]: Online\n", cpuid());
}
scheduler();

View file

@ -23,6 +23,8 @@
#define UART0 0x10000000L
#define UART0_IRQ 10
#define QEMU_POWER 0x100000
// virtio mmio interface
#define VIRTIO0 0x10001000
#define VIRTIO0_IRQ 1

View file

@ -100,5 +100,6 @@ sys_trace(void)
void
sys_halt(void)
{
/* TODO: Implement sys_halt */
(*(volatile u32 *)QEMU_POWER) = 0x5555;
panic("sys_poweroff");
}

View file

@ -21,6 +21,9 @@ kvmmake(void)
kpgtbl = (pagetable_t)kalloc();
memset(kpgtbl, 0, PGSIZE);
// Map qemu
kvmmap(kpgtbl, QEMU_POWER, QEMU_POWER, PGSIZE, PTE_R | PTE_W);
// uart registers
kvmmap(kpgtbl, UART0, UART0, PGSIZE, PTE_R | PTE_W);

View file

@ -4,6 +4,7 @@
int
main(int argc, char *argv[])
{
printf("System powering down...\n");
halt();
return 0;
}