From 679b5a3b8d3ee8dedbeef5853b0536ea80547edc Mon Sep 17 00:00:00 2001 From: pjht Date: Sun, 12 Jul 2020 14:30:16 -0500 Subject: [PATCH] Add syscall macros and remove mailbox IPC --- Makefile | 14 +- init/main.c | 65 ++- initrd_drv/initrd_drv | Bin 34500 -> 34356 bytes kernel/cpu/i386/isr.c | 76 +-- kernel/cpu/i386/mailboxes.c | 120 ----- kernel/cpu/i386/mailboxes.h | 13 - kernel/rpc.c | 8 + kernel/rpc.h | 17 + libc/errno.c | 7 +- libc/initrd.c | 9 +- libc/mailboxes.c | 35 -- libc/memory.c | 16 +- libc/stdio.c | 833 ++++++++++++++--------------- libc/tasking.c | 25 +- pci/pci | Bin 37380 -> 37244 bytes sysroot/usr/include/mailboxes.h | 26 - sysroot/usr/include/sys/syscalls.h | 24 + sysroot/usr/include/tasking.h | 1 - 18 files changed, 580 insertions(+), 709 deletions(-) delete mode 100644 kernel/cpu/i386/mailboxes.c delete mode 100644 kernel/cpu/i386/mailboxes.h create mode 100644 kernel/rpc.c create mode 100644 kernel/rpc.h delete mode 100644 libc/mailboxes.c delete mode 100644 sysroot/usr/include/mailboxes.h create mode 100644 sysroot/usr/include/sys/syscalls.h diff --git a/Makefile b/Makefile index 9f2ad0e..ddb87ef 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ debug: os.iso kernel/kernel.elf @$(GDB) #gdbgui -g i386-elf-gdb --project $(CWD) -os.iso: kernel/kernel.elf init vfs devfs initrd vga_drv initrd_drv pci +os.iso: kernel/kernel.elf init # vfs devfs initrd vga_drv initrd_drv pci @cp kernel/kernel.elf sysroot/boot @cd initrd; tar -f ../sysroot/boot/initrd.tar -c * @grub-mkrescue -o $@ sysroot >/dev/null 2>/dev/null @@ -39,27 +39,27 @@ crts: kernel/crt0.o @cp $^ sysroot/usr/lib init: crts libc - @cd $@ && make + cd $@ && make @cp $@/$@ initrd/$@ vfs: crts libc - @cd $@ && make + cd $@ && make @cp $@/$@ initrd/$@ devfs: crts libc - @cd $@ && make + cd $@ && make @cp $@/$@ initrd/$@ pci: crts libc - @cd $@ && make + cd $@ && make @cp $@/$@ initrd/$@ vga_drv: crts libc - @cd $@ && make + cd $@ && make @cp $@/$@ initrd/$@ initrd_drv: crts libc - @cd $@ && make + cd $@ && make @cp $@/$@ initrd/$@ kernel/kernel.elf: $(OBJ) $(ASM_OBJ) $(S_ASM_OBJ) sysroot/usr/lib/libc.a diff --git a/init/main.c b/init/main.c index 441fbb8..88e32b6 100644 --- a/init/main.c +++ b/init/main.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -97,38 +96,38 @@ char load_task(uint32_t datapos,char* initrd) { return 1; } -char load_task_devfs(uint32_t datapos) { - serial_print("load_task_devfs\n"); - FILE* initrd=fopen("/dev/initrd","r"); - elf_header header; - fseek(initrd,datapos,SEEK_SET); - fread(&header,sizeof(elf_header),1,initrd); - if (header.magic!=ELF_MAGIC) { - serial_print("Bad magic number\n"); - return 0; - } else { - void* cr3=new_address_space(); - for (int i=0;i0) { - fseek(initrd,pheader.offset+datapos,SEEK_SET); - fread(ptr,sizeof(char),pheader.filesz,initrd); - } - copy_data(cr3,ptr,pheader.memsz,(void*)pheader.vaddr); - } - createTaskCr3((void*)header.entry,cr3); - } - return 1; -} +// char load_task_devfs(uint32_t datapos) { +// serial_print("load_task_devfs\n"); +// FILE* initrd=fopen("/dev/initrd","r"); +// elf_header header; +// fseek(initrd,datapos,SEEK_SET); +// fread(&header,sizeof(elf_header),1,initrd); +// if (header.magic!=ELF_MAGIC) { +// serial_print("Bad magic number\n"); +// return 0; +// } else { +// void* cr3=new_address_space(); +// for (int i=0;i0) { +// fseek(initrd,pheader.offset+datapos,SEEK_SET); +// fread(ptr,sizeof(char),pheader.filesz,initrd); +// } +// copy_data(cr3,ptr,pheader.memsz,(void*)pheader.vaddr); +// } +// createTaskCr3((void*)header.entry,cr3); +// } +// return 1; +// } int main() { diff --git a/initrd_drv/initrd_drv b/initrd_drv/initrd_drv index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L||sHTaow9KJJt*PwXsufc z15GPhs)C|D*wWN0f~#>TY^!X&L#(L_)>q%uR6c!*)fH7O!OFJaP2f##8B$)^QrXa3 zIaV+|ULz!$S!57DZmMh;d<_Tc0&k&;tAo-zxiC`veyXW&s=Uf=sBEjnfK>(S>dmGG zrCQNI16KrkGe$m5Eo+eR}P#FI2_>p z>f(27+P$@4YrTl5=)A2N9yYQpxA$^INS5n|Ak)yw$GHYu<#q;M!Y)sM8xv6Z}-=+W$@dIaWt@f zTf#UA*gml^&IGnEU>Gk&#qC>@STSFUd~&0_Hmk#*2aN)f|h}%-4SQ^a`;6-?CjB zKnt*ach3B~fbFv{;|;*}ohsukz*j3^hzEc-AVc`aom79z547>+8^7#`oBis+d zRE!DVOtHZyf%(^5d(4gizuKW1qa!8cTiB|{RO3`c{vBWgL&&dV);|Fpf;}7m1K7Tq zW&Ua4Zgc(2v=lCbVE^#I0S~I^G*gpL-9s_*f(XNcUo>6pbv!~yM z>UC?or(x?(b@f?4SIXtt)ZUSy^I#}Bw5KB{ig#6Cju7YQ^^VLa6~8&ExhNi;?f61j zOdoB?)gB)t#D7!N#$2r(-|dYw2)%B6-+xRC(ECFp{~)yJmSWI&|;^^o`pZ7ta fEDQiXZNvyVzA;rhd>4N6qKl9`f42}nX375n-JxYL diff --git a/kernel/cpu/i386/isr.c b/kernel/cpu/i386/isr.c index 1e8c82e..9539377 100644 --- a/kernel/cpu/i386/isr.c +++ b/kernel/cpu/i386/isr.c @@ -9,13 +9,11 @@ #include "../tasking.h" #include "interrupt.h" #include "address_spaces.h" -#include "mailboxes.h" -#include #include #include #include "serial.h" #include - +#include void irq_handler(registers_t* r); static isr_t interrupt_handlers[256]; @@ -194,33 +192,34 @@ void isr_handler(registers_t* r) { halt(); break; case 80: - if (r->eax==1) { - tss_stack_reset(); + switch (r->eax) { + case SYSCALL_YIELD: tasking_yield(r); - // r->ds=0x23; - // r->ss=0x23; - // r->cs=0x1B; - } else if (r->eax==2) { + break; + case SYSCALL_CREATEPROC_NEW_ADDR_SPACE: tasking_createTask((void*)r->ebx); - } else if (r->eax==3) { + break; + case SYSCALL_ALLOC_MEM: serial_printf("PID %d is allocating %d pages\n",getPID(),r->ebx); r->ebx=(uint32_t)alloc_pages(r->ebx); - } else if (r->eax==4) { + break; + case SYSCALL_ALLOC_MEM_VIRT: alloc_pages_virt(r->ebx,(void*)r->ecx); - } else if (r->eax==5) { + break; + case SYSCALL_GET_ERRNO_ADDR: r->ebx=(uint32_t)tasking_get_errno_address(); - } else if (r->eax==6) { - kernel_mailbox_get_msg(r->ebx,(Message*)r->ecx,r->edx); - } else if (r->eax==7) { - kernel_mailbox_send_msg((Message*)r->ebx); - } else if (r->eax==8) { + break; + case SYSCALL_NEW_ADDR_SPACE: r->ebx=(uint32_t)paging_new_address_space(); - } else if (r->eax==9) { + break; + case SYSCALL_CREATEPROC_GIVEN_ADDR_SPACE: tasking_createTaskCr3KmodeParam((void*)r->ebx,(void*)r->ecx,0,0,0,0,0); - } else if (r->eax==10) { + break; + case SYSCALL_ADDR_SPACES_COPY_DATA: serial_printf("address_spaces_copy_data(0x%x,0x%x,0x%x,0x%x);\n",(void*)r->ebx,(void*)r->ecx,r->edx,(void*)r->esi); address_spaces_copy_data((void*)r->ebx,(void*)r->ecx,r->edx,(void*)r->esi); - } else if (r->eax==11) { + break; + case SYSCALL_PRIV_MAP_PAGES: if (!currentTask->priv) { r->ebx=0; return; @@ -228,32 +227,41 @@ void isr_handler(registers_t* r) { void* virt_addr=find_free_pages(r->ecx); map_pages(virt_addr,(void*)r->ebx,r->ecx,1,1); r->ebx=(uint32_t)virt_addr; - } else if (r->eax==12) { + break; + case SYSCALL_CREATEPROC_GIVEN_ADDR_SPACE_W_ARGS: tasking_createTaskCr3KmodeParam((void*)r->ebx,(void*)r->ecx,0,1,r->edx,1,r->esi); - } else if (r->eax==13) { + break; + case SYSCALL_ADDR_SPACES_PUT_DATA: r->ebx=(uint32_t)address_spaces_put_data((void*)r->ebx,(void*)r->ecx,r->edx); - } else if (r->eax==14) { - r->ebx=kernel_mailbox_new((uint16_t)r->ebx,(char*)r->ecx); - } else if (r->eax==15) { + break; + case SYSCALL_YIELD_TO_PID: tasking_yieldToPID(r->ebx); - } else if (r->eax==16) { + break; + case SYSCALL_SERIAL_PRINT: serial_write_string((char*)r->ebx); - } else if (r->eax==17) { + break; + case SYSCALL_EXIT: tasking_exit((uint8_t)r->ebx); - } else if (r->eax==18) { + break; + case SYSCALL_GET_INITRD_SZ: serial_printf("Initrd size is %d bytes\n",initrd_sz); r->ebx=initrd_sz; - } else if (r->eax==19) { + break; + case SYSCALL_COPY_INITRD: serial_printf("Copying initrd\n"); memcpy((char*)r->ebx,initrd,initrd_sz); - } else if (r->eax==20) { + break; + case SYSCALL_GET_PID: r->ebx=(pid_t)getPID(); - } else if (r->eax==21) { - r->ebx=kernel_mailbox_find_by_name((char*)r->ebx); - } else if (r->eax==22) { + break; + case SYSCALL_BLOCK: tasking_block(r->ebx); - } else if (r->eax==23) { + break; + case SYSCALL_UNBLOCK: tasking_unblock(r->ebx); + break; + default: + break; } break; } diff --git a/kernel/cpu/i386/mailboxes.c b/kernel/cpu/i386/mailboxes.c deleted file mode 100644 index 04d48bf..0000000 --- a/kernel/cpu/i386/mailboxes.c +++ /dev/null @@ -1,120 +0,0 @@ - #include "mailboxes.h" -#include "kmalloc.h" -#include -#include -#include -#include "serial.h" -#include "paging.h" -#include "pmem.h" -#include "../tasking.h" - -Mailbox* mailboxes=(Mailbox*)0xF6400000; -uint32_t next_box=1; - -uint32_t kernel_mailbox_new(uint16_t size,char* name) { - if (next_box==262144) { - serial_printf("Attempted to create a mailbox, but failed\n"); - return 0xFFFFFFFF; - } - mailboxes[next_box].rd=0; - mailboxes[next_box].wr=0; - mailboxes[next_box].size=size; - mailboxes[next_box].msg_store=kmalloc(sizeof(Message)*size); - if (strlen(name)>19) { - name[20]='\0'; - } - strcpy(mailboxes[next_box].name,name); - serial_printf("PID %d created mailbox %s\n",getPID(),mailboxes[next_box].name); - next_box++; - return next_box-1; -} - -void kernel_mailbox_free(uint32_t box) { - kfree(mailboxes[box].msg_store); -} - -void kernel_mailbox_send_msg(Message* user_msg) { - if (user_msg->to==0) { - serial_printf("Box %s attempted to send to box 0!\n",mailboxes[user_msg->from].name); - return; - } - Mailbox mailbox=mailboxes[user_msg->to]; - uint32_t num_pages=(user_msg->size/4096)+1; - serial_printf("Storing data in pmem\n"); - void* phys_addr=pmem_alloc(num_pages); - void* virt_addr=find_free_pages(num_pages); - map_pages(virt_addr,phys_addr,num_pages,0,1); - serial_printf("Mapped into vmem\n"); - memcpy(virt_addr,user_msg->msg,user_msg->size); - unmap_pages(virt_addr,num_pages); - serial_printf("Stored data in pmem\n"); - mailbox.msg_store[mailbox.wr].msg=phys_addr; - mailbox.msg_store[mailbox.wr].from=user_msg->from; - mailbox.msg_store[mailbox.wr].to=user_msg->to; - mailbox.msg_store[mailbox.wr].size=user_msg->size; - mailbox.wr++; - if (mailbox.wr==mailbox.size) { - mailbox.wr=0; - } - if (mailbox.wr==mailbox.rd) { - mailbox.wr--; - if (mailbox.wr==(2^32)-1) { - mailbox.wr=mailbox.size-1; - } - } - mailboxes[user_msg->to]=mailbox; - serial_printf("Message sent from box %s to box %s\n",mailboxes[user_msg->from].name,mailboxes[user_msg->to].name); -} - -void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz) { - Mailbox mailbox=mailboxes[box]; - if (mailbox.msg_store[mailbox.rd].from==0) { - recv_msg->size=0; - recv_msg->from=0; - serial_printf("Box %s attempted to get a message, but there were none.\n",mailboxes[box].name); - mailboxes[box]=mailbox; - return; - } - recv_msg->from=mailbox.msg_store[mailbox.rd].from; - recv_msg->to=mailbox.msg_store[mailbox.rd].to; - recv_msg->size=mailbox.msg_store[mailbox.rd].size; - if (buffer_szsize=mailbox.msg_store[mailbox.rd].size; - recv_msg->from=0; - serial_printf("Box %s attempted to get the message from box %s, but the buffer was too small.\n",mailboxes[box].name,mailboxes[mailbox.msg_store[mailbox.rd].from].name); - serial_printf("Expected message at most %d big, but got message sized %d.\n",buffer_sz,mailbox.msg_store[mailbox.rd].size); - mailboxes[box]=mailbox; - return; - } - if (buffer_sz>mailbox.msg_store[mailbox.rd].size) { - serial_printf("Warning: buffer sized for message %d big, but got message sized %d.\n",buffer_sz,mailbox.msg_store[mailbox.rd].size); - } - Message msg=mailbox.msg_store[mailbox.rd]; - uint32_t num_pages=(msg.size/4096)+1; - void* virt_addr=find_free_pages(num_pages); - map_pages(virt_addr,msg.msg,num_pages,0,1); - memcpy(recv_msg->msg,virt_addr,mailbox.msg_store[mailbox.rd].size); - // unmap_pages(virt_addr,num_pages); - // pmem_free(((uint32_t)msg.msg)>>12,num_pages); - // kfree(mailbox.msg_store[mailbox.rd].msg); - mailbox.msg_store[mailbox.rd].from=0; - uint32_t orig_rd=mailbox.rd; - mailbox.rd++; - if (mailbox.rd==mailbox.size) { - mailbox.rd=0; - } - if (mailbox.rd>mailbox.wr && !(orig_rd>mailbox.wr)) { - mailbox.rd=mailbox.wr; - } - serial_printf("Box %s got a message from box %s.\n",mailboxes[box].name,mailboxes[recv_msg->from].name); - mailboxes[box]=mailbox; -} - -uint32_t kernel_mailbox_find_by_name(char* name) { - for (uint32_t i=1;i -#include - -uint32_t kernel_mailbox_new(uint16_t size,char* name); -void kernel_mailbox_free(uint32_t box); -void kernel_mailbox_send_msg(Message* user_msg); -void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz); -uint32_t kernel_mailbox_find_by_name(char* name); - -#endif diff --git a/kernel/rpc.c b/kernel/rpc.c new file mode 100644 index 0000000..f7ce7f4 --- /dev/null +++ b/kernel/rpc.c @@ -0,0 +1,8 @@ +#include "cpu/tasking.h" +#include +#include "rpc.h" +void rpc_init_struct(TaskRPCStruct* info) { + info->pendingrpc = 0; + info->callingpid = 0; +} + diff --git a/kernel/rpc.h b/kernel/rpc.h new file mode 100644 index 0000000..597168c --- /dev/null +++ b/kernel/rpc.h @@ -0,0 +1,17 @@ +#ifndef RPC_H +#define RPC_H + +typedef struct RPCFuncInfo { + char name[32]; + char* (*code)(char*); +} RPCFuncInfo; + +typedef struct TaskRPCStruct { + int pendingrpc; + int callingpid; +} TaskRPCStruct; + + +void rpc_init_struct(TaskRPCStruct* info); + +#endif diff --git a/libc/errno.c b/libc/errno.c index a213907..43d3f6e 100644 --- a/libc/errno.c +++ b/libc/errno.c @@ -1,7 +1,12 @@ +#include + +#define QUAUX(X) #X +#define QU(X) QUAUX(X) + int* __get_errno_address() { int* address; asm volatile(" \ - mov $5, %%eax; \ + mov $" QU(SYSCALL_GET_ERRNO_ADDR) ", %%eax; \ int $80; \ ":"=b"(address):); return address; diff --git a/libc/initrd.c b/libc/initrd.c index 2c6f585..56f9fab 100644 --- a/libc/initrd.c +++ b/libc/initrd.c @@ -1,7 +1,12 @@ +#include + +#define QUAUX(X) #X +#define QU(X) QUAUX(X) + long initrd_sz() { long size; asm volatile(" \ - mov $18, %%eax; \ + mov $" QU(SYSCALL_GET_INITRD_SZ) ", %%eax; \ int $80; \ ":"=b"(size)); return size; @@ -9,7 +14,7 @@ long initrd_sz() { void initrd_get(char* initrd) { asm volatile(" \ - mov $19, %%eax; \ + mov $" QU(SYSCALL_COPY_INITRD) ", %%eax; \ int $80; \ "::"b"(initrd)); } diff --git a/libc/mailboxes.c b/libc/mailboxes.c deleted file mode 100644 index 1662bbd..0000000 --- a/libc/mailboxes.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -uint32_t mailbox_new(uint16_t size,char* name) { - uint32_t box; - asm volatile(" \ - mov $14, %%eax; \ - int $80; \ - ":"=b"(box):"b"(size),"c"(name)); - return box; -} - -void mailbox_send_msg(Message* msg) { - asm volatile(" \ - mov $7, %%eax; \ - int $80; \ - "::"b"(msg)); -} - -void mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz) { - asm volatile(" \ - mov $6, %%eax; \ - int $80; \ - "::"b"(box),"c"(recv_msg),"d"(buffer_sz)); -} - - -uint32_t mailbox_find_by_name(char* name) { - uint32_t box; - asm volatile(" \ - mov $21, %%eax; \ - int $80; \ - ":"=b"(box):"b"(name)); - return box; -} diff --git a/libc/memory.c b/libc/memory.c index 48b19c6..7bc8830 100644 --- a/libc/memory.c +++ b/libc/memory.c @@ -1,9 +1,13 @@ #include +#include + +#define QUAUX(X) #X +#define QU(X) QUAUX(X) void* alloc_memory(uint32_t num_pages) { void* address; asm volatile(" \ - mov $3, %%eax; \ + mov $" QU(SYSCALL_ALLOC_MEM) ", %%eax; \ int $80; \ ":"=b"(address):"b"(num_pages)); return address; @@ -11,7 +15,7 @@ void* alloc_memory(uint32_t num_pages) { void alloc_memory_virt(uint32_t num_pages,void* addr) { asm volatile(" \ - mov $4, %%eax; \ + mov $" QU(SYSCALL_ALLOC_MEM_VIRT) ", %%eax; \ int $80; \ "::"b"(num_pages),"c"(addr)); } @@ -19,7 +23,7 @@ void alloc_memory_virt(uint32_t num_pages,void* addr) { void* new_address_space() { void* cr3; asm volatile(" \ - mov $8, %%eax; \ + mov $" QU(SYSCALL_NEW_ADDR_SPACE) ", %%eax; \ int $80; \ ":"=b"(cr3)); return cr3; @@ -27,7 +31,7 @@ void* new_address_space() { void copy_data(void* cr3, void* data,uint32_t size,void* virt_addr) { asm volatile(" \ - mov $10, %%eax; \ + mov $" QU(SYSCALL_ADDR_SPACES_COPY_DATA) ", %%eax; \ int $80; \ "::"b"(cr3),"c"(data),"d"(size),"S"(virt_addr)); } @@ -35,7 +39,7 @@ void copy_data(void* cr3, void* data,uint32_t size,void* virt_addr) { void* put_data(void* cr3, void* data,uint32_t size) { void* virt_addr; asm volatile(" \ - mov $13, %%eax; \ + mov $" QU(SYSCALL_ADDR_SPACES_PUT_DATA) ", %%eax; \ int $80; \ ":"=b"(virt_addr):"b"(cr3),"c"(data),"d"(size)); return virt_addr; @@ -44,7 +48,7 @@ void* put_data(void* cr3, void* data,uint32_t size) { void* map_phys(void* phys_addr,uint32_t num_pages) { void* virt_addr; asm volatile(" \ - mov $11, %%eax; \ + mov $" QU(SYSCALL_PRIV_MAP_PAGES) ", %%eax; \ int $80; \ ":"=b"(virt_addr):"b"(phys_addr),"c"(num_pages)); return virt_addr; diff --git a/libc/stdio.c b/libc/stdio.c index a50c402..f35db89 100644 --- a/libc/stdio.c +++ b/libc/stdio.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,447 +6,447 @@ #include #include #include -#define VFS_PID 2 +// #define VFS_PID 2 -static uint32_t box; -static uint32_t vfs_box; +// static uint32_t box; +// static uint32_t vfs_box; FILE* __stdio_stdin; FILE* __stdio_stdout; FILE* __stdio_stderr; void __stdio_init() { - char name[256]; - strcpy(name,"stdio"); - int name_end_index=strlen(name); - char* name_end=&name[name_end_index]; - int_to_ascii(getpid(),name_end); - box=mailbox_new(16,name); - __stdio_stdin=malloc(sizeof(FILE*)); - *__stdio_stdin=0; - __stdio_stdout=malloc(sizeof(FILE*)); - *__stdio_stdout=1; - __stdio_stderr=malloc(sizeof(FILE*)); - *__stdio_stderr=2; - vfs_box=mailbox_find_by_name("vfs"); - if (vfs_box==0) { - serial_print("Cannot find VFS box\n"); - } +// char name[256]; +// strcpy(name,"stdio"); +// int name_end_index=strlen(name); +// char* name_end=&name[name_end_index]; +// int_to_ascii(getpid(),name_end); +// box=mailbox_new(16,name); +// __stdio_stdin=malloc(sizeof(FILE*)); +// *__stdio_stdin=0; +// __stdio_stdout=malloc(sizeof(FILE*)); +// *__stdio_stdout=1; +// __stdio_stderr=malloc(sizeof(FILE*)); +// *__stdio_stderr=2; +// vfs_box=mailbox_find_by_name("vfs"); +// if (vfs_box==0) { +// serial_print("Cannot find VFS box\n"); +// } } -static vfs_message* make_msg(vfs_message_type type,const char* mode,const char* path, uint32_t fd, int data) { - vfs_message* msg_data=malloc(sizeof(vfs_message)); - msg_data->type=type; - msg_data->id=0; - msg_data->fd=fd; - msg_data->data=data; - msg_data->in_progress=0; - msg_data->orig_mbox=box; - if (mode!=NULL) { - strcpy(&msg_data->mode[0],mode); - } - if (path!=NULL) { - strcpy(&msg_data->path[0],path); - } - return msg_data; -} +// static vfs_message* make_msg(vfs_message_type type,const char* mode,const char* path, uint32_t fd, int data) { +// vfs_message* msg_data=malloc(sizeof(vfs_message)); +// msg_data->type=type; +// msg_data->id=0; +// msg_data->fd=fd; +// msg_data->data=data; +// msg_data->in_progress=0; +// msg_data->orig_mbox=box; +// if (mode!=NULL) { +// strcpy(&msg_data->mode[0],mode); +// } +// if (path!=NULL) { +// strcpy(&msg_data->path[0],path); +// } +// return msg_data; +// } -FILE* fopen(char* filename,char* mode) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return NULL; - } - if (strlen(filename)>4096 || strlen(mode)>10) { - return NULL; - } - vfs_message* msg_data=make_msg(VFS_OPEN,mode,filename,0,0); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - vfs_message* vfs_msg=(vfs_message*)msg.msg; - if (vfs_msg->flags) { - free(msg.msg); - return NULL; - } else { - FILE* file=malloc(sizeof(FILE)); - *file=vfs_msg->fd; //We're using pointers to FILE even though it's a uint32_t so we can expand to a struct if needed - free(msg.msg); - return file; - } -} +// FILE* fopen(char* filename,char* mode) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return NULL; +// } +// if (strlen(filename)>4096 || strlen(mode)>10) { +// return NULL; +// } +// vfs_message* msg_data=make_msg(VFS_OPEN,mode,filename,0,0); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// vfs_message* vfs_msg=(vfs_message*)msg.msg; +// if (vfs_msg->flags) { +// free(msg.msg); +// return NULL; +// } else { +// FILE* file=malloc(sizeof(FILE)); +// *file=vfs_msg->fd; //We're using pointers to FILE even though it's a uint32_t so we can expand to a struct if needed +// free(msg.msg); +// return file; +// } +// } -int putc(int c, FILE* stream) __attribute__ ((alias ("fputc"))); +// int putc(int c, FILE* stream) __attribute__ ((alias ("fputc"))); -int fputc(int c, FILE* stream) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return EOF; - } - char str[]={c,'\0'}; - if (fputs(str,stream)==0) { - return c; - } else { - return EOF; - } - return EOF; -} +// int fputc(int c, FILE* stream) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return EOF; +// } +// char str[]={c,'\0'}; +// if (fputs(str,stream)==0) { +// return c; +// } else { +// return EOF; +// } +// return EOF; +// } -int getc(FILE* stream) __attribute__ ((alias ("fgetc"))); +// int getc(FILE* stream) __attribute__ ((alias ("fgetc"))); -int fgetc(FILE* stream) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return EOF; - } - char c[2]; - if (fgets(&c[0],1,stream)==NULL) { - return EOF; - } else { - return c[0]; - } - return EOF; -} +// int fgetc(FILE* stream) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return EOF; +// } +// char c[2]; +// if (fgets(&c[0],1,stream)==NULL) { +// return EOF; +// } else { +// return c[0]; +// } +// return EOF; +// } -char* gets(char* s) { - return fgets(s,INT_MAX,stdin); -} +// char* gets(char* s) { +// return fgets(s,INT_MAX,stdin); +// } -char* fgets(char* str,int count,FILE* stream) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return NULL; - } - vfs_message* msg_data=make_msg(VFS_GETS,NULL,NULL,*stream,count); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - vfs_message* vfs_msg=(vfs_message*)msg.msg; - if (vfs_msg->flags) { - free(vfs_msg); - return NULL; - } else { - msg.msg=str; - mailbox_get_msg(box,&msg,count); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,count); - } - str[vfs_msg->data]='\0'; - free(vfs_msg); - return str; - } - free(vfs_msg); - return NULL; -} +// char* fgets(char* str,int count,FILE* stream) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return NULL; +// } +// vfs_message* msg_data=make_msg(VFS_GETS,NULL,NULL,*stream,count); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// vfs_message* vfs_msg=(vfs_message*)msg.msg; +// if (vfs_msg->flags) { +// free(vfs_msg); +// return NULL; +// } else { +// msg.msg=str; +// mailbox_get_msg(box,&msg,count); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,count); +// } +// str[vfs_msg->data]='\0'; +// free(vfs_msg); +// return str; +// } +// free(vfs_msg); +// return NULL; +// } -size_t fread(void* buffer_ptr,size_t size,size_t count,FILE* stream) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return 0; - } - char* buffer=(char*)buffer_ptr; - size_t bytes=size*count; - vfs_message* msg_data=make_msg(VFS_GETS,NULL,NULL,*stream,bytes); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - vfs_message* vfs_msg=(vfs_message*)msg.msg; - if (vfs_msg->flags) { - free(vfs_msg); - return 0; - } else { - msg.msg=buffer; - mailbox_get_msg(box,&msg,bytes); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,bytes); - } - free(vfs_msg); - return count; - } - free(vfs_msg); - return 0; -} +// size_t fread(void* buffer_ptr,size_t size,size_t count,FILE* stream) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return 0; +// } +// char* buffer=(char*)buffer_ptr; +// size_t bytes=size*count; +// vfs_message* msg_data=make_msg(VFS_GETS,NULL,NULL,*stream,bytes); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// vfs_message* vfs_msg=(vfs_message*)msg.msg; +// if (vfs_msg->flags) { +// free(vfs_msg); +// return 0; +// } else { +// msg.msg=buffer; +// mailbox_get_msg(box,&msg,bytes); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,bytes); +// } +// free(vfs_msg); +// return count; +// } +// free(vfs_msg); +// return 0; +// } -int puts(const char *s) { - char* str=malloc(sizeof(char)*(strlen(s)+2)); - strcpy(str,s); - str[strlen(s)]='\n'; - str[strlen(s)+1]='\0'; - serial_print(str); - int code=fputs(str,stdout); - free(str); - return code; -} +// int puts(const char *s) { +// char* str=malloc(sizeof(char)*(strlen(s)+2)); +// strcpy(str,s); +// str[strlen(s)]='\n'; +// str[strlen(s)+1]='\0'; +// serial_print(str); +// int code=fputs(str,stdout); +// free(str); +// return code; +// } -int fputs(const char* s, FILE* stream) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return EOF; - } - vfs_message* msg_data=make_msg(VFS_PUTS,NULL,NULL,*stream,strlen(s)); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - msg.msg=(char*)s; - msg.size=strlen(s); - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - msg.msg=msg_data; - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - vfs_message* vfs_msg=(vfs_message*)msg.msg; - if (vfs_msg->flags) { - free(msg.msg); - return EOF; - } else { - free(msg.msg); - return 0; - } - free(msg.msg); - return EOF; -} +// int fputs(const char* s, FILE* stream) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return EOF; +// } +// vfs_message* msg_data=make_msg(VFS_PUTS,NULL,NULL,*stream,strlen(s)); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// msg.msg=(char*)s; +// msg.size=strlen(s); +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// msg.msg=msg_data; +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// vfs_message* vfs_msg=(vfs_message*)msg.msg; +// if (vfs_msg->flags) { +// free(msg.msg); +// return EOF; +// } else { +// free(msg.msg); +// return 0; +// } +// free(msg.msg); +// return EOF; +// } -size_t fwrite(void* buffer_ptr,size_t size,size_t count,FILE* stream) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return 0; - } - char* buffer=(char*)buffer_ptr; - size_t bytes=size*count; - vfs_message* msg_data=make_msg(VFS_PUTS,NULL,NULL,*stream,bytes); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - msg.msg=buffer; - msg.size=bytes; - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - msg.msg=msg_data; - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - vfs_message* vfs_msg=(vfs_message*)msg.msg; - if (vfs_msg->flags) { - free(msg.msg); - return 0; - } else { - free(msg.msg); - return count; - } - free(msg.msg); - return 0; -} +// size_t fwrite(void* buffer_ptr,size_t size,size_t count,FILE* stream) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return 0; +// } +// char* buffer=(char*)buffer_ptr; +// size_t bytes=size*count; +// vfs_message* msg_data=make_msg(VFS_PUTS,NULL,NULL,*stream,bytes); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// msg.msg=buffer; +// msg.size=bytes; +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// msg.msg=msg_data; +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// vfs_message* vfs_msg=(vfs_message*)msg.msg; +// if (vfs_msg->flags) { +// free(msg.msg); +// return 0; +// } else { +// free(msg.msg); +// return count; +// } +// free(msg.msg); +// return 0; +// } -void register_fs(const char* name,uint32_t mbox) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return; - } - vfs_message* msg_data=make_msg(VFS_REGISTER_FS,name,NULL,mbox,0); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - free(msg.msg); - yieldToPID(VFS_PID); - msg.msg=malloc(sizeof(vfs_message)); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - free(msg.msg); -} +// void register_fs(const char* name,uint32_t mbox) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return; +// } +// vfs_message* msg_data=make_msg(VFS_REGISTER_FS,name,NULL,mbox,0); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// free(msg.msg); +// yieldToPID(VFS_PID); +// msg.msg=malloc(sizeof(vfs_message)); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// free(msg.msg); +// } -void mount(char* file,char* type,char* path) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return; - } - vfs_message* msg_data=make_msg(VFS_MOUNT,type,path,0,strlen(file)+1); - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - msg.msg=file; - msg.size=strlen(file)+1; - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - msg.msg=msg_data; - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - free(msg.msg); -} +// void mount(char* file,char* type,char* path) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return; +// } +// vfs_message* msg_data=make_msg(VFS_MOUNT,type,path,0,strlen(file)+1); +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// msg.msg=file; +// msg.size=strlen(file)+1; +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// msg.msg=msg_data; +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// free(msg.msg); +// } -int vfprintf(FILE* stream,const char* format,va_list arg) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return EOF; - } - int c; - for(;*format!='\0';format++) { - if(*format!='%') { - c=fputc(*format,stream); - if (c==EOF) { - return EOF; - } - continue; - } - format++; - switch(*format) { - case 'c': { - int i=va_arg(arg,int); - c=fputc(i,stream); - if (c==EOF) { - return EOF; - } - break; - } - case 'd': { - int i=va_arg(arg,int); //Fetch Decimal/Integer argument - if(i<0) { - i=-i; - fputc('-',stream); - } - char str[11]; - int_to_ascii(i,str); - c=fputs(str,stream); - if (c==EOF) { - return EOF; - } - break; - } - // case 'o': { - // int i=va_arg(arg,unsigned int); //Fetch Octal representation - // puts(convert(i,8)); - // break; - // } - case 's': { - char* s=va_arg(arg,char*); - c=fputs(s,stream); - if (c==EOF) { - return EOF; - } - break; - } - case 'x': { - uint32_t i=va_arg(arg,uint32_t); - char str[11]; - str[0]='\0'; - hex_to_ascii(i,str); - c=fputs(str,stream); - if (c==EOF) { - return EOF; - } - break; - } - } - } - return 1; -} +// int vfprintf(FILE* stream,const char* format,va_list arg) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return EOF; +// } +// int c; +// for(;*format!='\0';format++) { +// if(*format!='%') { +// c=fputc(*format,stream); +// if (c==EOF) { +// return EOF; +// } +// continue; +// } +// format++; +// switch(*format) { +// case 'c': { +// int i=va_arg(arg,int); +// c=fputc(i,stream); +// if (c==EOF) { +// return EOF; +// } +// break; +// } +// case 'd': { +// int i=va_arg(arg,int); //Fetch Decimal/Integer argument +// if(i<0) { +// i=-i; +// fputc('-',stream); +// } +// char str[11]; +// int_to_ascii(i,str); +// c=fputs(str,stream); +// if (c==EOF) { +// return EOF; +// } +// break; +// } +// // case 'o': { +// // int i=va_arg(arg,unsigned int); //Fetch Octal representation +// // puts(convert(i,8)); +// // break; +// // } +// case 's': { +// char* s=va_arg(arg,char*); +// c=fputs(s,stream); +// if (c==EOF) { +// return EOF; +// } +// break; +// } +// case 'x': { +// uint32_t i=va_arg(arg,uint32_t); +// char str[11]; +// str[0]='\0'; +// hex_to_ascii(i,str); +// c=fputs(str,stream); +// if (c==EOF) { +// return EOF; +// } +// break; +// } +// } +// } +// return 1; +// } -int fprintf(FILE* stream,const char* format,...) { - va_list arg; - int code; - va_start(arg,format); - code=vfprintf(stream,format,arg); - va_end(arg); - if (code) { - return strlen(format); - } else { - return EOF; - } -} +// int fprintf(FILE* stream,const char* format,...) { +// va_list arg; +// int code; +// va_start(arg,format); +// code=vfprintf(stream,format,arg); +// va_end(arg); +// if (code) { +// return strlen(format); +// } else { +// return EOF; +// } +// } -int printf(const char* format,...) { - va_list arg; - int code; - va_start(arg,format); - code=vfprintf(stdout,format,arg); - va_end(arg); - if (code) { - return strlen(format); - } else { - return EOF; - } -} +// int printf(const char* format,...) { +// va_list arg; +// int code; +// va_start(arg,format); +// code=vfprintf(stdout,format,arg); +// va_end(arg); +// if (code) { +// return strlen(format); +// } else { +// return EOF; +// } +// } -int fseek(FILE* stream,long offset,int origin) { - if (vfs_box==0) { - serial_print("The VFS box has not been found\n"); - return -1; - } - vfs_message* msg_data=make_msg(VFS_SEEK,NULL,NULL,*stream,origin); - msg_data->pos=offset; - Message msg; - msg.from=box; - msg.to=vfs_box; - msg.msg=msg_data; - msg.size=sizeof(vfs_message); - mailbox_send_msg(&msg); - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - while (msg.from==0) { - yieldToPID(VFS_PID); - mailbox_get_msg(box,&msg,sizeof(vfs_message)); - } - vfs_message* vfs_msg=(vfs_message*)msg.msg; - if (vfs_msg->flags) { - free(vfs_msg); - return -1; - } else { - free(vfs_msg); - return 0; - } -} +// int fseek(FILE* stream,long offset,int origin) { +// if (vfs_box==0) { +// serial_print("The VFS box has not been found\n"); +// return -1; +// } +// vfs_message* msg_data=make_msg(VFS_SEEK,NULL,NULL,*stream,origin); +// msg_data->pos=offset; +// Message msg; +// msg.from=box; +// msg.to=vfs_box; +// msg.msg=msg_data; +// msg.size=sizeof(vfs_message); +// mailbox_send_msg(&msg); +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// while (msg.from==0) { +// yieldToPID(VFS_PID); +// mailbox_get_msg(box,&msg,sizeof(vfs_message)); +// } +// vfs_message* vfs_msg=(vfs_message*)msg.msg; +// if (vfs_msg->flags) { +// free(vfs_msg); +// return -1; +// } else { +// free(vfs_msg); +// return 0; +// } +// } -void rescan_vfs() { - vfs_box=mailbox_find_by_name("vfs"); -} +// void rescan_vfs() { +// vfs_box=mailbox_find_by_name("vfs"); +// } diff --git a/libc/tasking.c b/libc/tasking.c index 9a78ac6..a31581f 100644 --- a/libc/tasking.c +++ b/libc/tasking.c @@ -1,38 +1,35 @@ #include #include #include +#include + +#define QUAUX(X) #X +#define QU(X) QUAUX(X) void yield() { asm volatile(" \ - mov $1, %eax; \ + mov $" QU(SYSCALL_YIELD) ", %eax; \ int $80; \ "); } -void createTask(void* task) { - asm volatile(" \ - mov $2, %%eax; \ - int $80; \ - "::"b"(task)); -} - void createTaskCr3(void* task,void* cr3) { asm volatile(" \ - mov $9, %%eax; \ + mov $" QU(SYSCALL_CREATEPROC_GIVEN_ADDR_SPACE) ", %%eax; \ int $80; \ "::"b"(task),"c"(cr3)); } void createTaskCr3Param(void* task,void* cr3,uint32_t param1,uint32_t param2) { asm volatile(" \ - mov $12, %%eax; \ + mov $" QU(SYSCALL_CREATEPROC_GIVEN_ADDR_SPACE_W_ARGS) ", %%eax; \ int $80; \ "::"b"(task),"c"(cr3),"d"(param1),"S"(param2)); } void yieldToPID(uint32_t pid) { asm volatile(" \ - mov $15, %%eax; \ + mov $" QU(SYSCALL_YIELD_TO_PID) ", %%eax; \ int $80; \ "::"b"(pid)); } @@ -40,7 +37,7 @@ void yieldToPID(uint32_t pid) { __attribute__((noreturn)) void exit(int code) { code=code&0xff; asm volatile(" \ - mov $17, %%eax; \ + mov $" QU(SYSCALL_EXIT) ", %%eax; \ int $80; \ "::"b"(code)); for(;;); @@ -49,14 +46,14 @@ __attribute__((noreturn)) void exit(int code) { void blockTask(TaskState state) { asm volatile(" \ - mov $22, %%eax; \ + mov $" QU(SYSCALL_BLOCK) ", %%eax; \ int $80; \ "::"b"(state)); } void unblockTask(pid_t pid) { asm volatile(" \ - mov $23, %%eax; \ + mov $" QU(SYSCALL_UNBLOCK) ", %%eax; \ int $80; \ "::"b"(pid)); } diff --git a/pci/pci b/pci/pci index 3f4403e8e35404e2bcbfdffea02a6a5b0146358e..fb242af7ca5a175544481b430a5b8c5d314903dc 100755 GIT binary patch delta 7750 zcmZ`;33yc1**@paojZ4OXC{-(gzT9llYL{evKj~`kU-d_E*NA95Xu%HEG{@GVnIL{ zz80#4wc^&=N<&@xYinz5)mkeBEwlwGKTvE@qy_b-^yh!SbLR%=^Za?9IrqHZe!laa zbI(0_4tn;x zy4m(TnzQFTLahE}a9zX2)hjQGj+3j;nQhm&@Bat)>}Pphm*gm^{X4B|m}{XHJ-{|j zB`X_$&syK$TYcj5)#vnaSCsiPimu6=^w^U;{*%1 zX{#sV$$tvn6aKE(JoBWsxrK6)b{O?cdy{^a^pJd*>Z}sEklL&=Ih^8Fhs|70map0F z7E_C_&F;QTzwu3w`zX&}BDYY3zf8`d1^y-(p;!E+@=H45zttAJlga}#T|x04M)bEJxPB_sgmzdAhk@}9i-!dESiv7 zYb&3lt*Ij=BvKpY3sey*(;i8tY2h%ng>r0(ujsMR9r6VIcc?_ZN=e}=xtsch%j9yJ z8vdFs^4G5I;bzV5f15t-FD8WA&aP&4eV%T}P#eJU z|2f)%XpbP&ac7f~$eURq+v%pv!*V-$vxcX(D;XY0YtfaXIYnppe|K7zS+KsrT=(WH zJ%kXy9k+RM%bSzdot|jZ(rsGTvckVgx~HgAn{|xV7ClAH#rdvfvzE}p;%Y7B80{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mc{?C!&MwgK2W zLy$ckhZb*9ja{(-9)jLF4UqmZVC#F!AA#U02&~&DGI#-a0Zw|eV+4nReSHoM_9tNL z?vLz`16!LsVHF)}U1tXD$HF@aeKQWmG_~THgFTCibv+lM24`VlT^kZU2W;(#gjayD zBSz>0=D;WKQ;i*%8>Dvv|KrE1kroR$8Q9v2NnZ$Dflt<%G5tVb`uPrVL}Wx`An3vI z`qP-fc;Hu&foKfh2yERc5#epXnQf}^c1*tr*t#wu{hh$pkonN#HNe)vm-IgZKCoUj z=EJ}2K|2Jiujs)x;J1LSSxon{){PAj><6}P9|`{y*gCusrkmzY9FVOcdXEP z#xg=zmLy1q;Bv|gmI1sD4iO(NLmZ5*v!8=Qx^O1@GT?t=2u{UtC9riWC;d3!;TTf7 zAt77`Ouy&iA%}bhDmOohlg+7^K_dhgkh0tuUIKg<2rRq`*t*Un!U*t-^a6?5cK}<5 zMbaMtrk{cFkPe?g#kyoB{UPAD_xa3UL`d)#2)1{2z4_yAuA6TF@vHk=_1Ny;f1`(Y zjoq|H;pfF~9tb&Tur}o2t3vd2B#4U-xE-{IcR+GR#BT{XR^yk-)rkEWF>K3M_?4`% zBU^iAAY((t4XAyKgY`tQ3biqFFmPfIYUTL$_KMd#vXwFG#MzEK&+c`M(J%iv!L!jK XGn%H=w_{q0%4oJW2(R3O - - -typedef struct { - void* msg; - uint32_t from; - uint32_t to; - uint32_t size; -} Message; - -typedef struct { - uint32_t rd; - uint32_t wr; - uint16_t size; - Message* msg_store; - char name[20]; -} Mailbox; - -uint32_t mailbox_new(uint16_t size,char* name); -void mailbox_send_msg(Message* msg); -void mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz); -uint32_t mailbox_find_by_name(char* name); - -#endif diff --git a/sysroot/usr/include/sys/syscalls.h b/sysroot/usr/include/sys/syscalls.h new file mode 100644 index 0000000..39f7d81 --- /dev/null +++ b/sysroot/usr/include/sys/syscalls.h @@ -0,0 +1,24 @@ +#ifndef SYSCALLS_H + +#define SYSCALLS_H + +#define SYSCALL_YIELD 1 +#define SYSCALL_CREATEPROC_NEW_ADDR_SPACE 2 +#define SYSCALL_ALLOC_MEM 3 +#define SYSCALL_ALLOC_MEM_VIRT 4 +#define SYSCALL_GET_ERRNO_ADDR 5 +#define SYSCALL_NEW_ADDR_SPACE 8 +#define SYSCALL_CREATEPROC_GIVEN_ADDR_SPACE 9 +#define SYSCALL_ADDR_SPACES_COPY_DATA 10 +#define SYSCALL_PRIV_MAP_PAGES 11 +#define SYSCALL_CREATEPROC_GIVEN_ADDR_SPACE_W_ARGS 12 +#define SYSCALL_ADDR_SPACES_PUT_DATA 13 +#define SYSCALL_YIELD_TO_PID 15 +#define SYSCALL_SERIAL_PRINT 16 +#define SYSCALL_EXIT 17 +#define SYSCALL_GET_INITRD_SZ 18 +#define SYSCALL_COPY_INITRD 19 +#define SYSCALL_GET_PID 20 +#define SYSCALL_BLOCK 22 +#define SYSCALL_UNBLOCK 23 +#endif diff --git a/sysroot/usr/include/tasking.h b/sysroot/usr/include/tasking.h index 6918f21..7e6f6d8 100644 --- a/sysroot/usr/include/tasking.h +++ b/sysroot/usr/include/tasking.h @@ -16,7 +16,6 @@ typedef enum TaskState { void yield(); void yieldToPID(uint32_t pid); -void createTask(void* task); void createTaskCr3(void* task,void* cr3); void createTaskCr3Param(void* task,void* cr3,uint32_t param1,uint32_t param2); char isPrivleged(uint32_t pid);