This commit is contained in:
Freya Murphy 2024-10-07 19:33:05 -04:00
parent 83d2c4fa37
commit d373d2f398
Signed by: freya
GPG key ID: 744AB800E383AE52
3 changed files with 21 additions and 10 deletions

View file

@ -3,16 +3,16 @@
#include <inc/mmu.h> #include <inc/mmu.h>
#include <inc/memlayout.h> #include <inc/memlayout.h>
# Shift Right Logical # Shift Right Logical
#define SRL(val, shamt) (((val) >> (shamt)) & ~(-1 << (32 - (shamt)))) #define SRL(val, shamt) (((val) >> (shamt)) & ~(-1 << (32 - (shamt))))
################################################################### ###################################################################
# The kernel (this code) is linked at address ~(KERNBASE + 1 Meg), # The kernel (this code) is linked at address ~(KERNBASE + 1 Meg),
# but the bootloader loads it at address ~1 Meg. # but the bootloader loads it at address ~1 Meg.
# #
# RELOC(x) maps a symbol x from its link address to its actual # RELOC(x) maps a symbol x from its link address to its actual
# location in physical memory (its load address). # location in physical memory (its load address).
################################################################### ###################################################################
#define RELOC(x) ((x) - KERNBASE) #define RELOC(x) ((x) - KERNBASE)
@ -91,6 +91,6 @@ spin: jmp spin
.globl bootstack .globl bootstack
bootstack: bootstack:
.space KSTKSIZE .space KSTKSIZE
.globl bootstacktop .globl bootstacktop
bootstacktop: bootstacktop:

View file

@ -57,6 +57,19 @@ mon_kerninfo(int argc, char **argv, struct Trapframe *tf)
int int
mon_backtrace(int argc, char **argv, struct Trapframe *tf) mon_backtrace(int argc, char **argv, struct Trapframe *tf)
{ {
uint32_t *bp = (uint32_t *) read_ebp();
uint32_t ip;
cprintf("Stack backtrace:\n");
do {
ip = * (bp + 1);
cprintf("ebp %08x eip %08x args", bp, ip);
for (int i = 2; i < 7; i++)
cprintf(" %08x", * (bp + i));
cprintf("\n");
} while ((bp = (uint32_t *) *bp));
// Your code here. // Your code here.
return 0; return 0;
} }

View file

@ -205,11 +205,9 @@ vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
// (unsigned) octal // (unsigned) octal
case 'o': case 'o':
// Replace this with your code. num = getuint(&ap, lflag);
putch('X', putdat); base = 8;
putch('X', putdat); goto number;
putch('X', putdat);
break;
// pointer // pointer
case 'p': case 'p':