Xyris  0.5
Arch Namespace Reference

Namespaces

 CPU
 
 Memory
 

Data Structures

struct  stackframe
 

Functions

void haltAndCatchFire ()
 
void registersToString (char *buf, struct registers *regs)
 
void registersPrintInformation (struct registers *regs)
 

Function Documentation

◆ haltAndCatchFire()

void Arch::haltAndCatchFire ( )
inline

Disable interrupts and halts execution.

Definition at line 42 of file Arch.hpp.

43 {
44  while (true) {
45  asm volatile ("cli");
46  asm volatile ("hlt");
47  }
48 }
+ Here is the caller graph for this function:

◆ registersPrintInformation()

void Arch::registersPrintInformation ( struct registers regs)

Print register information to all kernel terminals (serial, framebuffer, etc.). Used for panic and debug screens.

Parameters
regsRegister structure

Definition at line 67 of file Arch.i686.cpp.

68 {
69  log_all("Exception: %lu (%s)\n\n", regs->int_num, exceptionStrings[regs->int_num]);
70  if (regs->err_code) {
71  log_all("Error code: %lu", regs->err_code);
72  }
73 
75  Registers::CR2 cr2 = Registers::readCR2();
76  int missing = regs->err_code & 0x1; // Page not present
77  int rw = regs->err_code & 0x2; // Write operation?
78  int us = regs->err_code & 0x4; // Processor was in user-mode?
79  int reserved = regs->err_code & 0x8; // Overwritten CPU-reserved bits of page entry?
80  int id = regs->err_code & 0x10; // Caused by an instruction fetch?
81 
82  const char* real = (missing ? "missing" : "present");
83  const char* rws = (rw ? "reading" : "writing");
84  const char* uss = (us ? "user-mode" : "kernel");
85  const char* avail = (reserved ? "reserved" : "available");
86  log_all("Page fault at 0x%08lX [ %s %s %s %s ] (id -> %i)\n", cr2.pageFaultAddr, real, rws, uss, avail, id);
87  }
88 }

◆ registersToString()

void Arch::registersToString ( char *  buf,
struct registers regs 
)

Write all register names and values as a string to a buffer. Provided buffer size must also take escape and control characters (for formatting) into account.

Parameters
bufBuffer to contain register information string
regsRegister structure

Definition at line 51 of file Arch.i686.cpp.

52 {
53  ksprintf(
54  buf,
55  "\033[31m DS:\033[0m 0x%08X\n"
56  "\033[31mEDI:\033[0m 0x%08X \033[31mESI:\033[0m 0x%08X \033[31mEBP:\033[0m 0x%08X \033[31mESP:\033[0m 0x%08X\n"
57  "\033[31mEAX:\033[0m 0x%08X \033[31mEBX:\033[0m 0x%08X \033[31mECX:\033[0m 0x%08X \033[31mEDX:\033[0m 0x%08X\n"
58  "\033[31mERR:\033[0m 0x%08X \033[31mEIP:\033[0m 0x%08X \033[31m CS:\033[0m 0x%08X\n"
59  "\033[31mFLG:\033[0m 0x%08X \033[31m SS:\033[0m 0x%08X\n\n",
60  regs->ds,
61  regs->edi, regs->esi, regs->ebp, regs->esp,
62  regs->eax, regs->ebx, regs->ecx, regs->edx,
63  regs->err_code, regs->eip, regs->cs, regs->eflags,
64  regs->ss);
65 }
+ Here is the call graph for this function:
registers::ecx
uint32_t ecx
Definition: regs.hpp:21
registers::eflags
uint32_t eflags
Definition: regs.hpp:23
ksprintf
int ksprintf(char *buf, const char *fmt,...)
Sends formatted output to a string.
Definition: printf.cpp:342
registers::esp
uint32_t esp
Definition: regs.hpp:23
Interrupts::EXCEPTION_PAGE_FAULT
@ EXCEPTION_PAGE_FAULT
Definition: isr.hpp:40
registers::ds
uint32_t ds
Definition: regs.hpp:20
registers::eax
uint32_t eax
Definition: regs.hpp:21
registers::ebp
uint32_t ebp
Definition: regs.hpp:21
registers::ss
uint32_t ss
Definition: regs.hpp:23
registers::edi
uint32_t edi
Definition: regs.hpp:21
registers::eip
uint32_t eip
Definition: regs.hpp:23
log_all
#define log_all(fmt,...)
Prints a statement to serial debugger and the kernel framebuffer. Max message size is 1024 (including...
Definition: stdio.hpp:59
registers::err_code
uint32_t err_code
Definition: regs.hpp:22
registers::edx
uint32_t edx
Definition: regs.hpp:21
exceptionStrings
const char exceptionStrings[33][32]
Definition: Arch.i686.cpp:31
registers::esi
uint32_t esi
Definition: regs.hpp:21
registers::ebx
uint32_t ebx
Definition: regs.hpp:21
registers::cs
uint32_t cs
Definition: regs.hpp:23
registers::int_num
uint32_t int_num
Definition: regs.hpp:22