mirror of
https://git.stationery.faith/corn/corn.git
synced 2024-11-24 20:00:03 +00:00
formatting
This commit is contained in:
parent
6b49a206c2
commit
85a9443704
14 changed files with 127 additions and 127 deletions
|
@ -10,7 +10,7 @@ size_t backtrace(void **dst, size_t len);
|
|||
size_t backtrace_ex(void **dst, size_t len, void *ip, void *bp);
|
||||
|
||||
// Log a backtrace
|
||||
void log_backtrace();
|
||||
void log_backtrace(void);
|
||||
|
||||
// same as log_backtrace with specified insruction and base pointer
|
||||
void log_backtrace_ex(void *ip, void *bp);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void enable_fpu();
|
||||
void enable_fpu(void);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define _PANIC_STR2(x) #x
|
||||
|
||||
#define panic(...) _panic_impl(_PANIC_STR(__LINE__), __FILE__, __VA_ARGS__)
|
||||
#define kassert(val, ...) do { if (!(val)) { panic(__VA_ARGS__); } } while(0)
|
||||
#define kassert(val, ...) do { if (!(val)) { panic(__VA_ARGS__); } } while (0)
|
||||
|
||||
__attribute__((format(printf, 3, 4)))
|
||||
_Noreturn void _panic_impl(char *line, char *file, char *format, ...);
|
||||
|
|
|
@ -26,7 +26,7 @@ size_t backtrace_ex(void **dst, size_t len, void *ip, void *bp) {
|
|||
return i;
|
||||
}
|
||||
|
||||
void log_backtrace() {
|
||||
void log_backtrace(void) {
|
||||
struct stackframe *rbp;
|
||||
__asm__ ("mov %%rbp, %0" : "=r"(rbp));
|
||||
log_backtrace_ex(rbp->rip, rbp->rbp);
|
||||
|
|
|
@ -103,7 +103,7 @@ static size_t debugger_read(char *buf, size_t len) {
|
|||
end:
|
||||
result = p - buf;
|
||||
kputc('\n');
|
||||
for(; p < buf + len; p++) {
|
||||
for (; p < buf + len; p++) {
|
||||
*p = 0;
|
||||
}
|
||||
return result;
|
||||
|
@ -161,24 +161,24 @@ static void debugger_print_regs(struct isr_regs *state) {
|
|||
kprintf("rflags: %#016lx (%lu)\n", state->rflags, state->rflags);
|
||||
struct rflags *rflags = (struct rflags *)state->rflags;
|
||||
kputs("rflags: ");
|
||||
if(rflags->cf) kputs("CF ");
|
||||
if(rflags->pf) kputs("PF ");
|
||||
if(rflags->af) kputs("AF ");
|
||||
if(rflags->zf) kputs("ZF ");
|
||||
if(rflags->sf) kputs("SF ");
|
||||
if(rflags->tf) kputs("TF ");
|
||||
if(rflags->if_) kputs("IF ");
|
||||
if(rflags->df) kputs("DF ");
|
||||
if(rflags->of) kputs("OF ");
|
||||
if(rflags->iopl) kputs("IOPL ");
|
||||
if(rflags->nt) kputs("NT ");
|
||||
if(rflags->md) kputs("MD ");
|
||||
if(rflags->rf) kputs("RF ");
|
||||
if(rflags->vm) kputs("VM ");
|
||||
if(rflags->ac) kputs("AC ");
|
||||
if(rflags->vif) kputs("VIF ");
|
||||
if(rflags->vip) kputs("VIP ");
|
||||
if(rflags->id) kputs("ID ");
|
||||
if (rflags->cf) kputs("CF ");
|
||||
if (rflags->pf) kputs("PF ");
|
||||
if (rflags->af) kputs("AF ");
|
||||
if (rflags->zf) kputs("ZF ");
|
||||
if (rflags->sf) kputs("SF ");
|
||||
if (rflags->tf) kputs("TF ");
|
||||
if (rflags->if_) kputs("IF ");
|
||||
if (rflags->df) kputs("DF ");
|
||||
if (rflags->of) kputs("OF ");
|
||||
if (rflags->iopl) kputs("IOPL ");
|
||||
if (rflags->nt) kputs("NT ");
|
||||
if (rflags->md) kputs("MD ");
|
||||
if (rflags->rf) kputs("RF ");
|
||||
if (rflags->vm) kputs("VM ");
|
||||
if (rflags->ac) kputs("AC ");
|
||||
if (rflags->vif) kputs("VIF ");
|
||||
if (rflags->vip) kputs("VIP ");
|
||||
if (rflags->id) kputs("ID ");
|
||||
kputs("\n");
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ static int debugger_handle_bkp_cmd(char *msg) {
|
|||
// list breakpoints
|
||||
for (int i = 0; i < 4; i++) {
|
||||
struct breakpoint bkp = bkps[i];
|
||||
if(!bkp.used) {
|
||||
if (!bkp.used) {
|
||||
kprintf("breakpoint %d: unset\n", i);
|
||||
continue;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ static int debugger_handle_bkp_cmd(char *msg) {
|
|||
}
|
||||
}
|
||||
|
||||
static void debugger_load_bkps() {
|
||||
static void debugger_load_bkps(void) {
|
||||
struct dr7 dr7;
|
||||
__asm__ volatile ("mov %%dr7, %0" : "=r"(dr7));
|
||||
dr7.g0 = bkps[0].enable & bkps[0].used;
|
||||
|
|
|
@ -26,4 +26,4 @@ struct isr_regs {
|
|||
uint64_t ss;
|
||||
};
|
||||
|
||||
void idt_init();
|
||||
void idt_init(void);
|
||||
|
|
|
@ -53,7 +53,7 @@ static void set_mode(uint16_t width, uint16_t height, uint16_t bit_depth, int lf
|
|||
(clear ? 0 : DATA_NO_CLEAR_MEM));
|
||||
}
|
||||
|
||||
volatile uint32_t* bochs_init(uint16_t width, uint16_t height, uint8_t bit_depth) {
|
||||
volatile uint32_t *bochs_init(uint16_t width, uint16_t height, uint8_t bit_depth) {
|
||||
|
||||
set_mode(width, height, bit_depth, true, true);
|
||||
|
||||
|
@ -66,7 +66,7 @@ volatile uint32_t* bochs_init(uint16_t width, uint16_t height, uint8_t bit_depth
|
|||
return NULL;
|
||||
|
||||
uint32_t bar0 = pci_rcfg_d(bochs, PCI_BAR0_D);
|
||||
uint32_t *addr = (uint32_t*) (uintptr_t) bar0;
|
||||
uint32_t *addr = (uint32_t *) (uintptr_t) bar0;
|
||||
addr = mmap(addr, width * height * bit_depth);
|
||||
|
||||
return addr;
|
||||
|
|
|
@ -88,7 +88,7 @@ static void print_device(struct pci_table_entry *entry) {
|
|||
}
|
||||
|
||||
static struct pci_table_entry *load_device(struct pci_device dev) {
|
||||
if(pci_table_next >= TABLE_LEN) panic("Too many PCI devices: limit is %d", TABLE_LEN);
|
||||
if (pci_table_next >= TABLE_LEN) panic("Too many PCI devices: limit is %d", TABLE_LEN);
|
||||
struct pci_table_entry *entry = &pci_table[pci_table_next++];
|
||||
entry->device = dev;
|
||||
uint32_t dword0 = pci_rcfg_d(dev, 0);
|
||||
|
@ -108,25 +108,25 @@ static struct pci_table_entry *load_device(struct pci_device dev) {
|
|||
void pci_init(void) {
|
||||
pci_table_next = 0;
|
||||
struct pci_device pcidev;
|
||||
for(int bus = 0; bus < 256; bus++) {
|
||||
for (int bus = 0; bus < 256; bus++) {
|
||||
pcidev.bus = bus;
|
||||
for(int dev = 0; dev < 32; dev++) {
|
||||
for (int dev = 0; dev < 32; dev++) {
|
||||
pcidev.device = dev;
|
||||
pcidev.function = 0;
|
||||
|
||||
uint16_t vendor = pci_rcfg_w(pcidev, 0);
|
||||
if(vendor == 0xFFFF) continue;
|
||||
if (vendor == 0xFFFF) continue;
|
||||
|
||||
load_device(pcidev);
|
||||
|
||||
uint8_t header_type = pci_rcfg_b(pcidev, 14);
|
||||
|
||||
if(!(header_type & 0x80)) continue;
|
||||
for(int func = 1; func < 8; func++) {
|
||||
if (!(header_type & 0x80)) continue;
|
||||
for (int func = 1; func < 8; func++) {
|
||||
pcidev.function = func;
|
||||
|
||||
uint16_t vendor = pci_rcfg_w(pcidev, 0);
|
||||
if(vendor == 0xFFFF) continue;
|
||||
if (vendor == 0xFFFF) continue;
|
||||
|
||||
load_device(pcidev);
|
||||
}
|
||||
|
@ -141,10 +141,10 @@ void pci_init(void) {
|
|||
|
||||
bool pci_findby_class(struct pci_device *dest, uint8_t class, uint8_t subclass, size_t *offset) {
|
||||
size_t o = 0;
|
||||
if(offset == NULL) offset = &o;
|
||||
for(; *offset < pci_table_next; (*offset)++) {
|
||||
if (offset == NULL) offset = &o;
|
||||
for (; *offset < pci_table_next; (*offset)++) {
|
||||
struct pci_table_entry *entry = &pci_table[*offset];
|
||||
if(entry->class == class && entry->subclass == subclass) {
|
||||
if (entry->class == class && entry->subclass == subclass) {
|
||||
*dest = entry->device;
|
||||
return true;
|
||||
}
|
||||
|
@ -154,10 +154,10 @@ bool pci_findby_class(struct pci_device *dest, uint8_t class, uint8_t subclass,
|
|||
|
||||
bool pci_findby_id(struct pci_device *dest, uint16_t device, uint16_t vendor, size_t *offset) {
|
||||
size_t o = 0;
|
||||
if(offset == NULL) offset = &o;
|
||||
for(; *offset < pci_table_next; (*offset)++) {
|
||||
if (offset == NULL) offset = &o;
|
||||
for (; *offset < pci_table_next; (*offset)++) {
|
||||
struct pci_table_entry *entry = &pci_table[*offset];
|
||||
if(entry->device_id == device && entry->vendor_id == vendor) {
|
||||
if (entry->device_id == device && entry->vendor_id == vendor) {
|
||||
*dest = entry->device;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <lib.h>
|
||||
|
||||
void enable_fpu() {
|
||||
void enable_fpu(void) {
|
||||
size_t cr4;
|
||||
uint16_t cw = 0x37F;
|
||||
__asm__ volatile ("mov %%cr4, %0" : "=r"(cr4));
|
||||
|
|
|
@ -174,7 +174,7 @@ static void read_memory_map(
|
|||
uintptr_t i = (uintptr_t)map->entries;
|
||||
kprintf("MEMORY MAP\n");
|
||||
char buf[20];
|
||||
for ( ;
|
||||
for (;
|
||||
i < (uintptr_t)map->entries + map->size;
|
||||
i += map->entry_size, idx++
|
||||
) {
|
||||
|
|
|
@ -113,7 +113,7 @@ void virtaddr_init(void) {
|
|||
}
|
||||
|
||||
static void merge_back(struct addr_node *node) {
|
||||
while(node->prev) {
|
||||
while (node->prev) {
|
||||
if (node->is_alloc != node->prev->is_alloc)
|
||||
break;
|
||||
struct addr_node *temp = node->prev;
|
||||
|
@ -129,7 +129,7 @@ static void merge_back(struct addr_node *node) {
|
|||
}
|
||||
|
||||
static void merge_forward(struct addr_node *node) {
|
||||
while(node->next) {
|
||||
while (node->next) {
|
||||
if (node->is_alloc != node->next->is_alloc)
|
||||
break;
|
||||
struct addr_node *temp = node->next;
|
||||
|
|
Loading…
Reference in a new issue