Consolidate formating

This commit is contained in:
Thomas Lovén 2022-01-17 00:38:43 +01:00
parent 121858ee31
commit f9b7390923
29 changed files with 139 additions and 354 deletions

View File

@ -8,8 +8,7 @@ extern gfx_context kernel_fb;
int *position = (void *)0x20000;
void thread1()
{
void thread1() {
int a = 1;
gfx_context *ctx = framebuffer_make_subcontext(&kernel_fb, 700, 300, 100, 100);
while(1) {
@ -18,25 +17,21 @@ void thread1()
draw_line(ctx, 0, 100, 50, ((a-1)%100), RGB(0,0,0));
draw_line(ctx, 0, 100, 50, (a%100), RGB(255,0,0));
flip(ctx);
sched_yield();
}
}
void thread2()
{
void thread2() {
int a = 0;
while(1) {
putCharacter(term_fb, *position, *position, RGB(0,255,255), RGB(0,0,0), 'A'+(a++%10));
flip(term_fb);
sched_yield();
}
}
void TEMP_test_scheduler()
{
void TEMP_test_scheduler() {
struct process *th1 = new_process(thread1);
scheduler_insert(th1);

View File

@ -11,8 +11,7 @@ void TEMP_test_scheduler();
struct kernel_boot_data_st kernel_boot_data;
void kmain(uint64_t multiboot_magic, void *multiboot_data)
{
void kmain(uint64_t multiboot_magic, void *multiboot_data) {
musl_init();
debug_info("Started kernel\n");
multiboot_init(multiboot_magic, P2V(multiboot_data));

View File

@ -31,17 +31,14 @@ struct mmap {
struct mmap_entry entries[];
}__attribute__((packed));
static int parse_multiboot2(struct taglist *tags)
{
static int parse_multiboot2(struct taglist *tags) {
struct mmap *mmap;
struct tag *tag = incptr(tags, sizeof(struct taglist));
kernel_boot_data.mboot_tags = tag;
kernel_boot_data.tags_length = tags->total_size;
while(tag->type)
{
switch(tag->type)
{
while(tag->type) {
switch(tag->type) {
case MBOOT2_TAG_BOOTLOADER:
kernel_boot_data.bootloader = (char *)tag->data;
break;
@ -69,21 +66,18 @@ static int parse_multiboot2(struct taglist *tags)
return 0;
}
int multiboot_init(uint64_t magic, void *mboot_info)
{
if(magic == MBOOT2_REPLY)
{
int multiboot_init(uint64_t magic, void *mboot_info) {
if(magic == MBOOT2_REPLY) {
kernel_boot_data.multiboot_version = 2;
parse_multiboot2(mboot_info);
}
else
} else {
return 1;
}
return 0;
}
int multiboot_get_memory_area(size_t index, uintptr_t *start, uintptr_t *end, uint32_t *type)
{
int multiboot_get_memory_area(size_t index, uintptr_t *start, uintptr_t *end, uint32_t *type) {
if(index >= kernel_boot_data.mmap_len) return 1;
struct mmap *mmap = kernel_boot_data.mmap;
@ -96,8 +90,7 @@ int multiboot_get_memory_area(size_t index, uintptr_t *start, uintptr_t *end, ui
return 0;
}
int multiboot_page_used(uintptr_t page)
{
int multiboot_page_used(uintptr_t page) {
#define within_page(st, l) (((uintptr_t)st + l) > page && (uintptr_t)st < (page + PAGE_SIZE))
size_t fb_size = 0;
@ -112,7 +105,8 @@ int multiboot_page_used(uintptr_t page)
within_page(kernel_boot_data.commandline, strlen(kernel_boot_data.commandline)) ||
within_page(kernel_boot_data.mmap, kernel_boot_data.mmap_size) ||
within_page(fb_start, fb_size) ||
0) {
0
) {
return 1;
}
return 0;

View File

@ -6,8 +6,7 @@
// ACPI Specification https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
struct rsdp // 5.2.5.3
{
struct rsdp { // 5.2.5.3
char signature[8];
uint8_t checksum;
char OEMID[6];
@ -19,8 +18,7 @@ struct rsdp // 5.2.5.3
uint8_t reserved[3]; // only if revision >= 2
}__attribute__((packed));
struct sdt_header // 5.2.6
{
struct sdt_header { // 5.2.6
char signature[4];
uint32_t length;
uint8_t revision;
@ -33,15 +31,13 @@ struct sdt_header // 5.2.6
uint8_t data[];
}__attribute__((packed));
struct madt_header // 5.2.12
{
struct madt_header { // 5.2.12
uint32_t controllerAddress;
uint32_t flags;
uint8_t fields[];
}__attribute__((packed));
struct madt_field
{
struct madt_field {
uint8_t type;
uint8_t length;
uint8_t data[];
@ -49,8 +45,7 @@ struct madt_field
// MADT field type: 0
#define MADT_TYPE_LAPIC 0
struct madt_data_lapic
{ // 5.2.12.2
struct madt_data_lapic { // 5.2.12.2
uint8_t id;
uint8_t apic;
uint32_t flags;
@ -58,8 +53,7 @@ struct madt_data_lapic
// MADT field type: 1
#define MADT_TYPE_IOAPIC 1
struct madt_data_ioapic
{ // 5.2.12.3
struct madt_data_ioapic { // 5.2.12.3
uint8_t id;
uint8_t reserved;
uint32_t address;
@ -68,8 +62,7 @@ struct madt_data_ioapic
// MADT field type: 2
#define MADT_TYPE_ISO 2
struct madt_data_iso
{ // 5.2.12.5
struct madt_data_iso { // 5.2.12.5
uint8_t bus;
uint8_t source;
uint32_t interrupt;
@ -77,8 +70,7 @@ struct madt_data_iso
}__attribute__((packed));
void acpi_parse()
{
void acpi_parse() {
int cpu_i=0;
struct rsdp *rsdp = kernel_boot_data.rsdp;
@ -86,23 +78,19 @@ void acpi_parse()
uint32_t *table = (void *)rsdt->data;
int entries = (rsdt->length - sizeof(struct sdt_header))/sizeof(uint32_t);
for(int i = 0; i < entries; i++)
{
for(int i = 0; i < entries; i++) {
struct sdt_header *h = P2V(table[i]);
if(h->length == 0) continue;
if(!strncmp(h->signature, "APIC", 4)) // 5.2.12
{
if(!strncmp(h->signature, "APIC", 4)) { // 5.2.12
struct madt_header *madt = P2V(h->data);
for(
struct madt_field *f = (void *)madt->fields;
(size_t)f <= (size_t)h + h->length;
f = incptr(f, f->length)
)
{
) {
switch(f->type) {
case MADT_TYPE_LAPIC:
{
case MADT_TYPE_LAPIC: {
struct madt_data_lapic *lapic = (void *)f->data;
struct cpu *cpu = P2V(pmm_alloc());
cpus[cpu_i++] = cpu;
@ -111,16 +99,14 @@ void acpi_parse()
cpu->flags = lapic->flags;
break;
}
case MADT_TYPE_IOAPIC:
{
case MADT_TYPE_IOAPIC: {
struct madt_data_ioapic *_ioapic = (void *)f->data;
ioapic.id = _ioapic->id;
ioapic.addr = _ioapic->address;
ioapic.base = _ioapic->base;
break;
}
case MADT_TYPE_ISO:
{
case MADT_TYPE_ISO: {
struct madt_data_iso *iso = (void *)f->data;
irq_redirects[iso->source] = iso->interrupt;
break;

View File

@ -24,43 +24,37 @@ union ioapic_redirection{
}__attribute__((packed));
};
static uint32_t ioapic_read(int reg)
{
static uint32_t ioapic_read(int reg) {
uint32_t volatile *ioregsel = P2V(ioapic.addr);
uint32_t volatile *iowin = P2V(ioapic.addr + 0x10);
*ioregsel = reg;
return *iowin;
}
static void ioapic_write(int reg, uint32_t value)
{
static void ioapic_write(int reg, uint32_t value) {
uint32_t volatile *ioregsel = P2V(ioapic.addr);
uint32_t volatile *iowin = P2V(ioapic.addr + 0x10);
*ioregsel = reg;
*iowin = value;
}
static uint64_t ioapic_read_redirection(int irq)
{
static uint64_t ioapic_read_redirection(int irq) {
union ioapic_redirection retval;
retval.l = ioapic_read(0x10 + 2*irq);
retval.h = ioapic_read(0x11 + 2*irq);
return retval.val;
}
static void ioapic_write_redirection(int irq, uint64_t val)
{
static void ioapic_write_redirection(int irq, uint64_t val) {
union ioapic_redirection value;
value.val = val;
ioapic_write(0x10 + 2*irq, value.l);
ioapic_write(0x11 + 2*irq, value.h);
}
void ioapic_init()
{
void ioapic_init() {
vmm_set_page(kernel_P4, (uintptr_t)P2V(ioapic.addr), ioapic.addr, PAGE_PRESENT | PAGE_WRITE | PAGE_GLOBAL);
union ioapic_redirection red;
for(int i = 0; i < 24; i++)
{
for(int i = 0; i < 24; i++) {
red.val = ioapic_read_redirection(i);
red.vector = IRQ_BASE+i;
red.flags = 0x0;
@ -73,8 +67,7 @@ void ioapic_init()
}
}
void apic_init()
{
void apic_init() {
// Enable local APIC
write_msr(MSR_APIC_BASE, read_msr(MSR_APIC_BASE) | APIC_MSR_ENABLE);

View File

@ -11,8 +11,7 @@ uint8_t irq_redirects[MAX_IRQS] = \
#define PIC2_ADDR 0xA0
#define PIC_INITIALIZE 0x10
#define PIC_SINGLE 0x02
static void pic_disable()
{
static void pic_disable() {
// Absolute minimum work to initialize and disable legacy PIC.
// Both the primary and secondary PIC will think they are alone
// in a MCS-80 arch computer but that doesn't matter since all
@ -27,13 +26,11 @@ static void pic_disable()
outb(PIC2_ADDR | 1, 0xFF);
}
void early_cpu_init()
{
void early_cpu_init() {
interrupt_init();
}
void cpu_init()
{
void cpu_init() {
acpi_parse();
pic_disable();
apic_init();

View File

@ -5,14 +5,12 @@
#define GDT_PRESENT (1<<15)
#define GDT_LONG (1<<21)
struct gdt
{
struct gdt {
uint32_t _;
uint32_t flags;
}__attribute__((packed));
struct gdtp
{
struct gdtp {
uint16_t len;
struct gdt *gdt;
}__attribute__((packed));

View File

@ -29,11 +29,9 @@ struct {
extern uintptr_t isr_table[];
int_handler_t int_handlers[NUM_INTERRUPTS];
void interrupt_init()
{
void interrupt_init() {
memset(idt, 0, sizeof(idt));
for(int i=0; i < NUM_INTERRUPTS; i++)
{
for(int i=0; i < NUM_INTERRUPTS; i++) {
idt[i].base_l = isr_table[i] & 0xFFFF;
idt[i].base_m = (isr_table[i] >> 16) & 0xFFFF;
idt[i].base_h = (isr_table[i] >> 32) & 0xFFFFFFFF;
@ -53,12 +51,10 @@ int_handler_t bind_interrupt(uint32_t num, int_handler_t fn) {
return old;
}
registers *int_handler(registers *r)
{
registers *int_handler(registers *r) {
if(int_handlers[r->int_no])
return int_handlers[r->int_no](r);
if(r->int_no < IRQ_BASE)
{
if(r->int_no < IRQ_BASE) {
debug_error("UNHANDLED EXCEPTION\n");
switch(r->int_no) {
case 14:

View File

@ -7,27 +7,22 @@ gfx_context kernel_fb;
gfx_context *term_fb;
static int setup = 0;
void fbterm_movecursor(unsigned int cursor)
{
void fbterm_movecursor(unsigned int cursor) {
(void) cursor;
}
void fbterm_flush(struct vga_cell *buffer)
{
void fbterm_flush(struct vga_cell *buffer) {
if(!setup) return;
int i = 0;
for(int row = 0; row < VGA_ROWS; row++)
{
for(int col=0; col < VGA_COLS; col++)
{
for(int row = 0; row < VGA_ROWS; row++) {
for(int col=0; col < VGA_COLS; col++) {
putCharacter(term_fb, col*8, row*16, 0xebdbb2, 0x282828, (char)buffer[i++].c);
}
}
flip(term_fb);
}
void fbterm_init(struct fbinfo *fbinfo)
{
void fbterm_init(struct fbinfo *fbinfo) {
kernel_fb.width = fbinfo->framebuffer_width;
kernel_fb.height = fbinfo->framebuffer_height;
kernel_fb.bpp = fbinfo->framebuffer_bpp/8;
@ -36,8 +31,11 @@ void fbterm_init(struct fbinfo *fbinfo)
kernel_fb.size = fbinfo->framebuffer_pitch * (kernel_fb.height);
kernel_fb.buffer = calloc(1, kernel_fb.size);
for(uintptr_t p = (uintptr_t)kernel_fb.addr; p < ((uintptr_t)kernel_fb.addr + kernel_fb.size); p += PAGE_SIZE)
{
for(
uintptr_t p = (uintptr_t)kernel_fb.addr;
p < ((uintptr_t)kernel_fb.addr + kernel_fb.size);
p += PAGE_SIZE
) {
vmm_set_page(kernel_P4, p, V2P(p), PAGE_GLOBAL | PAGE_WRITE | PAGE_PRESENT);
}

View File

@ -19,21 +19,17 @@ uint8_t format = 0x7;
static int terminal_type;
static void scroll()
{
while(cursor >= VGA_SIZE)
{
static void scroll() {
while(cursor >= VGA_SIZE) {
memmove(buffer, &buffer[VGA_POS(1,0)], VGA_COLS*(VGA_ROWS-1)*sizeof(struct vga_cell));
memset(&buffer[VGA_POS(VGA_ROWS-1, 0)], 0, VGA_COLS*sizeof(struct vga_cell));
cursor -= VGA_COLS;
}
}
static void terminal_write(char c)
{
static void terminal_write(char c) {
int doflush = 0;
switch(c)
{
switch(c) {
case '\n':
cursor += VGA_COLS - VGA_COL(cursor);
doflush = 1;
@ -42,8 +38,7 @@ static void terminal_write(char c)
buffer[cursor++] = (struct vga_cell){.c = c, .f = format};
}
scroll();
switch(terminal_type)
{
switch(terminal_type) {
case FRAMEBUFFER:
if(doflush)
fbterm_flush(buffer);
@ -57,14 +52,12 @@ static void terminal_write(char c)
}
}
static void terminal_putsn(char *s, size_t n)
{
static void terminal_putsn(char *s, size_t n) {
while(n--)
terminal_write(*s++);
}
long k_ioctl(long fd, long cmd, long arg3, long, long, long)
{
long k_ioctl(long fd, long cmd, long arg3, long, long, long) {
if(fd == 1 && cmd == 0x5413) {
struct {
unsigned short ws_row;
@ -81,14 +74,12 @@ long k_ioctl(long fd, long cmd, long arg3, long, long, long)
return retval;
}
long k_writev(long fd, long iov, long iovcnt, long, long, long)
{
long k_writev(long fd, long iov, long iovcnt, long, long, long) {
if(fd == 1)
{
size_t len = 0;
struct iovec *v = (void *) iov;
for(int i = 0; i < iovcnt; i++)
{
for(int i = 0; i < iovcnt; i++) {
terminal_putsn(v[i].iov_base, v[i].iov_len);
len += v[i].iov_len;
}
@ -103,8 +94,7 @@ void terminal_init(){
struct fbinfo *fbinfo = kernel_boot_data.fbinfo;
terminal_type = fbinfo->framebuffer_type;
switch(terminal_type)
{
switch(terminal_type) {
case FRAMEBUFFER:
fbterm_init(fbinfo);
break;

View File

@ -15,16 +15,14 @@ static void *vidmem;
static int setup = 0;
void vga_init(struct fbinfo *fbinfo)
{
void vga_init(struct fbinfo *fbinfo) {
(void) fbinfo;
vidmem = VGA_MEMORY;
memset(vidmem, 0, VGA_SIZE*sizeof(struct vga_cell));
setup = 1;
}
void vga_movecursor(unsigned int cursor)
{
void vga_movecursor(unsigned int cursor) {
if(!setup) return;
outb(VGA_ADDRESS_PORT, VGA_REGISTER_CURSOR_POS_LOW);
outb(VGA_DATA_PORT, (uint8_t)(cursor & 0xFF));
@ -32,8 +30,7 @@ void vga_movecursor(unsigned int cursor)
outb(VGA_DATA_PORT, (uint8_t)((cursor >> 8) & 0xFF));
}
void vga_flush(struct vga_cell *buffer)
{
void vga_flush(struct vga_cell *buffer) {
if(!setup) return;
memcpy(vidmem, buffer, VGA_SIZE*2);
}

View File

@ -1,13 +1,11 @@
#pragma once
#include <stdint.h>
static __inline void _outb(uint16_t port, uint8_t value)
{
static __inline void _outb(uint16_t port, uint8_t value) {
__asm__ volatile("outb %1, %0" : : "dN" (port), "a" (value));
}
static __inline uint8_t _inb(uint16_t port)
{
static __inline uint8_t _inb(uint16_t port) {
uint8_t ret;
__asm__ volatile("inb %1, %0" : "=a" (ret) : "dN" (port));
return ret;

View File

@ -1,8 +1,7 @@
#pragma once
#include <stdint.h>
struct process
{
struct process {
uint64_t pid;
void *stack_ptr;
uint64_t state;

View File

@ -9,15 +9,13 @@ syscall_handler syscall_handlers[440] = {
[SYSCALL_MMAP] = k_mmap,
};
syscall_handler set_syscall_handler(long num, syscall_handler handler)
{
syscall_handler set_syscall_handler(long num, syscall_handler handler) {
syscall_handler old = syscall_handlers[num];
syscall_handlers[num] = handler;
return old;
}
long syscall0(long num)
{
long syscall0(long num) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](0, 0, 0, 0, 0, 0);
@ -26,8 +24,7 @@ long syscall0(long num)
return retval;
}
long syscall1(long num, long a1)
{
long syscall1(long num, long a1) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](a1, 0, 0, 0, 0, 0);
@ -36,8 +33,7 @@ long syscall1(long num, long a1)
return retval;
}
long syscall2(long num, long a1, long a2)
{
long syscall2(long num, long a1, long a2) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](a1, a2, 0, 0, 0, 0);
@ -46,8 +42,7 @@ long syscall2(long num, long a1, long a2)
return retval;
}
long syscall3(long num, long a1, long a2, long a3)
{
long syscall3(long num, long a1, long a2, long a3) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](a1, a2, a3, 0, 0, 0);
@ -56,8 +51,7 @@ long syscall3(long num, long a1, long a2, long a3)
return retval;
}
long syscall4(long num, long a1, long a2, long a3, long a4)
{
long syscall4(long num, long a1, long a2, long a3, long a4) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](a1, a2, a3, a4, 0, 0);
@ -66,8 +60,7 @@ long syscall4(long num, long a1, long a2, long a3, long a4)
return retval;
}
long syscall5(long num, long a1, long a2, long a3, long a4, long a5)
{
long syscall5(long num, long a1, long a2, long a3, long a4, long a5) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](a1, a2, a3, a4, a5, 0);
@ -76,8 +69,7 @@ long syscall5(long num, long a1, long a2, long a3, long a4, long a5)
return retval;
}
long syscall6(long num, long a1, long a2, long a3, long a4, long a5, long a6)
{
long syscall6(long num, long a1, long a2, long a3, long a4, long a5, long a6) {
long retval = 0;
if(syscall_handlers[num])
retval = syscall_handlers[num](a1, a2, a3, a4, a5, a6);
@ -89,7 +81,6 @@ long syscall6(long num, long a1, long a2, long a3, long a4, long a5, long a6)
size_t auxv[] = {0};
void musl_init()
{
void musl_init() {
__libc.auxv = auxv;
}

View File

@ -4,10 +4,8 @@
static long _brk = KERNEL_BRK0;
static long _mmap = KERNEL_MMAP;
long k_brk(long brk, long, long, long, long, long)
{
if(brk)
{
long k_brk(long brk, long, long, long, long, long) {
if(brk) {
while(_brk < brk) {
vmm_set_page(kernel_P4, _brk, pmm_alloc(), PAGE_GLOBAL | PAGE_WRITE | PAGE_PRESENT);
_brk += PAGE_SIZE;
@ -18,8 +16,7 @@ long k_brk(long brk, long, long, long, long, long)
}
}
long k_mmap(long addr, long length, long prot, long flags, long fd, long offset)
{
long k_mmap(long addr, long length, long prot, long flags, long fd, long offset) {
(void)addr;
(void)prot;
(void)flags;
@ -27,8 +24,7 @@ long k_mmap(long addr, long length, long prot, long flags, long fd, long offset)
if(fd != -1)
PANIC("Unknown mmap request\n");
long retval = _mmap;
while(length > 0)
{
while(length > 0) {
vmm_set_page(kernel_P4, _mmap, pmm_alloc(), PAGE_GLOBAL | PAGE_WRITE | PAGE_PRESENT);
_mmap += PAGE_SIZE;
length -= PAGE_SIZE;

View File

@ -6,20 +6,16 @@
uint64_t kernel_P4;
void memory_init()
{
void memory_init() {
kernel_P4 = (uint64_t)&BootP4;
uint64_t start, end;
uint32_t type, i = 0;
while(!multiboot_get_memory_area(i++, &start, &end, &type))
{
for(uint64_t p = start; p < end; p += PAGE_SIZE)
{
while(!multiboot_get_memory_area(i++, &start, &end, &type)) {
for(uint64_t p = start; p < end; p += PAGE_SIZE) {
uint64_t vaddr = (uint64_t)P2V(p);
uint64_t page = vmm_get_page(kernel_P4, vaddr);
if(page == (uint64_t)-1 || !(page & PAGE_PRESENT))
{
if(page == (uint64_t)-1 || !(page & PAGE_PRESENT)) {
uint16_t flags = PAGE_GLOBAL | PAGE_WRITE | PAGE_PRESENT;
vmm_set_page(kernel_P4, vaddr, p, flags);
}

View File

@ -5,22 +5,19 @@
// Physical address of next page
uint64_t next = 0;
void pmm_free(uint64_t page)
{
void pmm_free(uint64_t page) {
*(uint64_t *)P2V(page) = next;
next = page;
}
uint64_t pmm_alloc()
{
uint64_t pmm_alloc() {
if(!next) return 0;
uint64_t page = next;
next = *(uint64_t *)P2V(page);
return page;
}
uint64_t pmm_calloc()
{
uint64_t pmm_calloc() {
uint64_t page = pmm_alloc();
memset(P2V(page), 0, PAGE_SIZE);
return page;

View File

@ -16,16 +16,14 @@
#define P1E(P4, addr) (PT(P2E(P4, addr))[P1_OFFSET(addr)])
static int P1_exists(uint64_t P4, uint64_t addr)
{
static int P1_exists(uint64_t P4, uint64_t addr) {
if (P4 && PRESENT(P4E(P4, addr)) && PRESENT(P3E(P4, addr)) && PRESENT(P2E(P4, addr)))
return 1;
return 0;
}
static int touch_P1(uint64_t P4, uint64_t addr, uint16_t flags)
{
static int touch_P1(uint64_t P4, uint64_t addr, uint16_t flags) {
if (!P4) return -1;
if(!PRESENT(P4E(P4, addr)) && (!(P4E(P4,addr) = pmm_calloc())))
@ -43,22 +41,19 @@ static int touch_P1(uint64_t P4, uint64_t addr, uint16_t flags)
return 0;
}
uint64_t new_P4()
{
uint64_t new_P4() {
uint64_t p4 = pmm_alloc();
memcpy(P2V(p4), (void *)kernel_P4, PAGE_SIZE);
return p4;
}
uint64_t vmm_get_page(uint64_t P4, uint64_t addr)
{
uint64_t vmm_get_page(uint64_t P4, uint64_t addr) {
if(P1_exists(P4, addr))
return P1E(P4, addr);
return -1;
}
int vmm_set_page(uint64_t P4, uint64_t addr, uint64_t page, uint16_t flags)
{
int vmm_set_page(uint64_t P4, uint64_t addr, uint64_t page, uint16_t flags) {
if(!P1_exists(P4, addr))
if(touch_P1(P4, addr, flags))
return -1;
@ -67,8 +62,7 @@ int vmm_set_page(uint64_t P4, uint64_t addr, uint64_t page, uint16_t flags)
return 0;
}
void vmm_clear_page(uint64_t P4, uint64_t addr, int free)
{
void vmm_clear_page(uint64_t P4, uint64_t addr, int free) {
if(!P1_exists(P4, addr))
return;

View File

@ -2,8 +2,7 @@
#include <proc.h>
#include <memory.h>
struct swtch_stack
{
struct swtch_stack {
uint64_t RBP;
uint64_t RBX;
uint64_t R12;
@ -18,8 +17,7 @@ static uint64_t next_pid = 1;
struct process *current_proc;
struct process *new_process(void (*function)(void))
{
struct process *new_process(void (*function)(void)) {
struct process *p = P2V(pmm_calloc());
p->pid = next_pid++;
p->stack_ptr = incptr(p, PAGE_SIZE - sizeof(struct swtch_stack));
@ -33,7 +31,6 @@ struct process *new_process(void (*function)(void))
return p;
}
struct process *proc()
{
struct process *proc() {
return current_proc;
}

View File

@ -8,16 +8,14 @@ static struct {
static struct process *scheduler_proc;
static struct process *scheduler_next()
{
static struct process *scheduler_next() {
struct process *ret = run_q.first;
if(run_q.first && !(run_q.first = run_q.first->q_next))
run_q.last = 0;
return ret;
}
void scheduler_insert(struct process *new)
{
void scheduler_insert(struct process *new) {
if(run_q.last) {
run_q.last->q_next = new;
run_q.last = new;
@ -27,10 +25,8 @@ void scheduler_insert(struct process *new)
new->q_next = 0;
}
void scheduler()
{
while(1)
{
void scheduler() {
while(1) {
struct process *new = 0;
while(!(new = scheduler_next()));
@ -43,14 +39,12 @@ void scheduler()
}
}
long k_sched_yield(long, long, long, long, long, long)
{
long k_sched_yield(long, long, long, long, long, long) {
switch_stack(&current_proc->stack_ptr, &scheduler_proc->stack_ptr);
return 0;
}
void start_scheduler()
{
void start_scheduler() {
scheduler_proc = new_process(scheduler);
scheduler_proc->pid = (uint64_t)-1;

View File

@ -11,15 +11,13 @@
#define STEP_X(ctx) 1
#define STEP_Y(ctx) (ctx)->pitch
void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr)
{
void putpixel(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr) {
if(x >= ctx->width || y >= ctx->height) return;
uint32_t *fb = (uint32_t *)ctx->buffer;
fb[PXL(ctx, x, y)] = clr;
}
void draw_line(gfx_context *ctx, uint64_t x0, uint64_t x1, uint64_t y0, uint64_t y1, uint32_t clr)
{
void draw_line(gfx_context *ctx, uint64_t x0, uint64_t x1, uint64_t y0, uint64_t y1, uint32_t clr) {
int64_t dx = x1 > x0 ? x1 - x0 : x0 - x1;
int64_t dy = y1 > y0 ? y1 - y0 : y0 - y1;
int sx = x1 > x0 ? 1 : -1;
@ -27,8 +25,7 @@ void draw_line(gfx_context *ctx, uint64_t x0, uint64_t x1, uint64_t y0, uint64_t
uint64_t x = x0, y = y0;
int64_t diff = dx - dy;
uint32_t *fb = (uint32_t *)ctx->buffer;
while(1)
{
while(1) {
fb[PXL(ctx, x, y)] = clr;
if(x == x1 && y == y1) break;
@ -42,61 +39,50 @@ void draw_line(gfx_context *ctx, uint64_t x0, uint64_t x1, uint64_t y0, uint64_t
}
}
void draw_rect(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height, uint32_t clr)
{
void draw_rect(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height, uint32_t clr) {
uint32_t *fb = (uint32_t *)ctx->buffer;
uint64_t l1 = PXL(ctx, x, y);
uint64_t l2 = PXL(ctx, x, y + height);
for(uint64_t _x = 0; _x <= width; _x++)
{
for(uint64_t _x = 0; _x <= width; _x++) {
fb[l1] = fb[l2] = clr;
l1 += STEP_X(ctx);
l2 += STEP_X(ctx);
}
l1 = PXL(ctx, x, y);
l2 = PXL(ctx, x + width, y);
for(uint64_t _y = 0; _y <= height; _y++)
{
for(uint64_t _y = 0; _y <= height; _y++) {
fb[l1] = fb[l2] = clr;
l1 += STEP_Y(ctx);
l2 += STEP_Y(ctx);
}
}
void fill_rect(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height, uint32_t clr)
{
void fill_rect(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height, uint32_t clr) {
uint32_t *fb = (uint32_t *)ctx->buffer;
uint64_t loc = PXL(ctx, x, y);
for(uint64_t _y = 0; _y <= height; _y++)
{
for(uint64_t _x = 0; _x <= width; _x += STEP_X(ctx))
{
for(uint64_t _y = 0; _y <= height; _y++) {
for(uint64_t _x = 0; _x <= width; _x += STEP_X(ctx)) {
fb[loc + _x] = clr;
}
loc += STEP_Y(ctx);
}
}
void putCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c)
{
void putCharacter(gfx_context *ctx, uint64_t x, uint64_t y, uint32_t clr_fg, uint32_t clr_bg, char c) {
unsigned char *chr = c ? font[(int)c-0x20]: font[0];
if(x >= ctx->width || y >= ctx->height) return;
uint32_t *fb = (uint32_t *)ctx->buffer;
uint64_t loc = y * ctx->pitch + x;
for(int row = 0; row < 16; row++)
{
for(int col = 0; col < 8; col++)
{
for(int row = 0; row < 16; row++) {
for(int col = 0; col < 8; col++) {
fb[loc+col] = ((chr[row]>>(7-col))&0x1) ? clr_fg : clr_bg;
}
loc += ctx->pitch;
}
}
void flip(gfx_context *ctx)
{
for(uint64_t y = 0; y < ctx->height; y++)
{
void flip(gfx_context *ctx) {
for(uint64_t y = 0; y < ctx->height; y++) {
memcpy(
incptr(ctx->addr, y*ctx->pitch*ctx->bpp),
incptr(ctx->buffer, y*ctx->pitch*ctx->bpp),
@ -104,8 +90,7 @@ void flip(gfx_context *ctx)
}
}
gfx_context *framebuffer_make_subcontext(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height)
{
gfx_context *framebuffer_make_subcontext(gfx_context *ctx, uint64_t x, uint64_t y, uint64_t width, uint64_t height) {
gfx_context *out = malloc(sizeof(gfx_context));
uint64_t loc = y * ctx->pitch + x;

View File

@ -1,98 +0,0 @@
// Font from https://github.com/atextor/unifont
char font[95][16] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x12, 0x12, 0x12, 0x7E, 0x24, 0x24, 0x7E, 0x48, 0x48, 0x48, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x08, 0x3E, 0x49, 0x48, 0x38, 0x0E, 0x09, 0x49, 0x3E, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x31, 0x4A, 0x4A, 0x34, 0x08, 0x08, 0x16, 0x29, 0x29, 0x46, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x22, 0x22, 0x1C, 0x39, 0x45, 0x42, 0x46, 0x39, 0x00, 0x00},
{0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x04, 0x00},
{0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x20, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x49, 0x2A, 0x1C, 0x2A, 0x49, 0x08, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x7F, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x24, 0x18, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x08, 0x18, 0x28, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x0C, 0x10, 0x20, 0x40, 0x40, 0x7E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x1C, 0x02, 0x02, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x14, 0x24, 0x44, 0x44, 0x7E, 0x04, 0x04, 0x04, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x02, 0x02, 0x02, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x1C, 0x20, 0x40, 0x40, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x3E, 0x02, 0x02, 0x02, 0x04, 0x38, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x10, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x02, 0x04, 0x08, 0x08, 0x00, 0x08, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x1C, 0x22, 0x4A, 0x56, 0x52, 0x52, 0x52, 0x4E, 0x20, 0x1E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x24, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x42, 0x42, 0x42, 0x42, 0x7C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x78, 0x44, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x44, 0x78, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7E, 0x40, 0x40, 0x40, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x40, 0x4E, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x44, 0x48, 0x50, 0x60, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x66, 0x66, 0x5A, 0x5A, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x62, 0x62, 0x52, 0x52, 0x4A, 0x4A, 0x46, 0x46, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x66, 0x3C, 0x03, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7C, 0x42, 0x42, 0x42, 0x7C, 0x48, 0x44, 0x44, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x40, 0x30, 0x0C, 0x02, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7F, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x41, 0x22, 0x22, 0x22, 0x14, 0x14, 0x08, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x5A, 0x5A, 0x66, 0x66, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x41, 0x41, 0x22, 0x22, 0x14, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x7E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x0E, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x02, 0x02, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00},
{0x00, 0x00, 0x18, 0x24, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00},
{0x00, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x02, 0x3E, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x40, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x7E, 0x40, 0x40, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x3A, 0x44, 0x44, 0x44, 0x38, 0x20, 0x3C, 0x42, 0x42, 0x3C},
{0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x48, 0x30},
{0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x42, 0x42, 0x42, 0x62, 0x5C, 0x40, 0x40},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3A, 0x46, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x02, 0x02},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x62, 0x42, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x42, 0x40, 0x30, 0x0C, 0x02, 0x42, 0x3C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0C, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x46, 0x3A, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x18, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x26, 0x1A, 0x02, 0x02, 0x3C},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7E, 0x00, 0x00},
{0x00, 0x00, 0x00, 0x0C, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x0C, 0x00},
{0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08},
{0x00, 0x00, 0x00, 0x30, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x10, 0x10, 0x08, 0x08, 0x30, 0x00},
{0x00, 0x00, 0x00, 0x31, 0x49, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
};

View File

@ -9,32 +9,25 @@ extern long syscall4(long, long, long, long, long);
extern long syscall5(long, long, long, long, long, long);
extern long syscall6(long, long, long, long, long, long, long);
static __inline long __syscall0(long n)
{
static __inline long __syscall0(long n) {
return syscall0(n);
}
static __inline long __syscall1(long n, long a1)
{
static __inline long __syscall1(long n, long a1) {
return syscall1(n, a1);
}
static __inline long __syscall2(long n, long a1, long a2)
{
static __inline long __syscall2(long n, long a1, long a2) {
return syscall2(n, a1, a2);
}
static __inline long __syscall3(long n, long a1, long a2, long a3)
{
static __inline long __syscall3(long n, long a1, long a2, long a3) {
return syscall3(n, a1, a2, a3);
}
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4)
{
static __inline long __syscall4(long n, long a1, long a2, long a3, long a4) {
return syscall4(n, a1, a2, a3, a4);
}
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
{
static __inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5) {
return syscall5(n, a1, a2, a3, a4, a5);
}
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
{
static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6) {
return syscall6(n, a1, a2, a3, a4, a5, a6);
}