64 if (active_mode->
stop != NULL)
69 if (active_mode->
start != NULL)
84 {
"help",
"Show this help text", cmd_display_help },
96 ((
const struct cmd *)c2)->
str);
103 for (
int i = 0; i <
arrsize(commands); i++) {
104 if (commands[i].
help == NULL)
107 commands[i].
str, commands[i].
help);
127 (local->
flags & 1) ?
"Usable" :
"Unusable");
165 while (addr != NULL) {
179 "Entering keycode mode. Hit Alt-Tab to exit.\n");
211 for (
int i = 0; i <
arrsize(commands); i++) {
212 if (!
strcmp(commands[i].str, cmd))
213 return commands[i].run();
237 while ((avail =
kb_getkey(&key)) !=
false) {
240 if (key.ch >= 32 && key.ch < 127) {
241 if (cmdlen <
arrsize(cmd) - 1) {
242 cmd[cmdlen] = key.
ch;
255 while (cmdlen > 0 && cmd[cmdlen - 1] ==
' ')
286 while ((avail =
kb_getkey(&key)) !=
false) {
290 "Keycode: \033[%c]%02x\033[-] meta=%02x '%c'\n",
299 "Keycode: \033[%c]%02x\033[-] meta=%02x\n",
319 active_mode->
start();
bool kb_getkey(key_t *key)
Return the available next key from the keyboard's input buffer.
#define KEYBRK_DOWN
Key-down break code.
static mode_t mode_keycode
int strcmp(const char *str1, const char *str2)
Compare two strings and return a value indicating their lexicographical order.
uint32_t ptr_io_apic
I/O APIC address.
Advanced configuration and power interface (ACPI) tables.
String and memory operations.
uint8_t apicid
I/O APIC ID.
A command descriptor, describing each command accepted in command mode.
static bool cmd_display_pcie()
__forceinline void halt()
uint8_t bus_end
End PCI bus number.
uint8_t ch
Character value, if valid.
void pagetable_create(pagetable_t *pt, void *vaddr, uint64_t size)
Create a new page table that can be used to associate virtual addresses with physical addresses...
static bool cmd_display_apic()
static void command_run()
uint32_t interrupt
Interrupt this soruce will signal.
uint32_t flags
Local APIC flags (bit 0 = usable)
void pagetable_destroy(pagetable_t *pt)
Destroy a page table.
void heap_free(heap_t *heap, void *ptr)
Free memory previously allocated with heap_alloc.
const struct acpi_madt_local_apic * acpi_next_local_apic(const struct acpi_madt_local_apic *prev)
Return a pointer to the next Local APIC structure entry in the MADT table.
uint32_t ptr_local_apic
Local APIC address.
MCFG entry, one or more of which appears at the tail of the acpi_mcfg struct.
void pagetable_activate(pagetable_t *pt)
Activate a page table on the CPU, so all virtual memory operations are performed relative to the page...
static bool cmd_test_heap()
static struct cmd commands[]
uint16_t seg_group
PCI segment group number.
A simple heap memory manager.
static bool command_exec(const char *cmd)
static void command_prompt()
static int cmp_cmds(const void *c1, const void *c2)
#define KEYBRK_UP
Key-up break code.
uint8_t apicid
Local APIC ID.
uint8_t source
Bus-relative source (IRQ)
const struct acpi_mcfg_addr * acpi_next_mcfg_addr(const struct acpi_mcfg_addr *prev)
Return a pointer to the next Mapped Configuration (MCFG) address entry, used for PCIe.
x86 CPU-specific function implementations.
void * heap_alloc(heap_t *heap, uint64_t size)
Allocate memory from a heap.
void tty_print(int id, const char *str)
Output a null-terminated string to the virtual console using the console's current text color and scr...
heap_t * heap_create(pagetable_t *pt, void *vaddr, uint64_t maxpages)
Create a new heap from which to allocate virtual memory.
MADT Interrupt Source Override (ISO) entry.
static bool cmd_display_help()
const struct acpi_madt * acpi_madt()
Return a pointer to the ACPI multiple APIC description table (MADT).
const struct acpi_madt_io_apic * acpi_next_io_apic(const struct acpi_madt_io_apic *prev)
Return a pointer to the next I/O APIC structure entry in the MADT table.
static mode_t mode_command
void qsort(void *base, size_t num, size_t size, sortcmp cmp)
Sort the elements of an array using a sort comparison function.
static bool cmd_switch_to_keycodes()
Multiple APIC description table (MADT).
void heap_destroy(heap_t *heap)
Destroy a heap, returning its memory to page table.
uint16_t flags
MPS INTI flags.
int tty_printf(int id, const char *format,...)
Output a printf-formatted string to the virtual console using the console's current text color and sc...
uint64_t base
Base address of configuration mechanism.
Teletype (console) screen text manipulation routines.
const struct acpi_madt_iso * acpi_next_iso(const struct acpi_madt_iso *prev)
Return a pointer to the next Interrupt Source Override (ISO) structure entry in the MADT table...
General utilities library.
#define META_ALT
Set while the alt key is pressed.
uint32_t interrupt_base
Interrupt # where interrupts start.
static void switch_mode(mode_t *mode)
#define arrsize(x)
Return the number of elements in the C array.
static mode_t * active_mode
static void keycode_run()
void tty_printc(int id, char ch)
Output a single character to the virtual console using the console's current text color and screen po...
static bool cmd_display_pci()
A record representing the state of the keyboard at the time a key was presssed or unpressed...
uint8_t bus_start
Start PCI bus number.