Add syscall macros and remove mailbox IPC

This commit is contained in:
pjht 2020-07-12 14:30:16 -05:00
parent ac7cc05113
commit 679b5a3b8d
18 changed files with 580 additions and 709 deletions

View File

@ -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

View File

@ -2,7 +2,6 @@
#include <grub/text_fb_info.h>
#include <ipc/vfs.h>
#include <elf.h>
#include <mailboxes.h>
#include <memory.h>
#include <tasking.h>
#include <stdlib.h>
@ -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;i<header.pheader_ent_nm;i++) {
elf_pheader pheader;
fseek(initrd,(header.prog_hdr)+(header.pheader_ent_sz*i)+datapos,SEEK_SET);
fread(&pheader,sizeof(elf_pheader),1,initrd);
serial_print("pheader.memsz=");
char str[256];
hex_to_ascii(pheader.memsz,str);
serial_print(str);
serial_print("\n");
char* ptr=alloc_memory(((pheader.memsz)/4096)+1);
memset(ptr,0,pheader.memsz);
if (pheader.filesz>0) {
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;i<header.pheader_ent_nm;i++) {
// elf_pheader pheader;
// fseek(initrd,(header.prog_hdr)+(header.pheader_ent_sz*i)+datapos,SEEK_SET);
// fread(&pheader,sizeof(elf_pheader),1,initrd);
// serial_print("pheader.memsz=");
// char str[256];
// hex_to_ascii(pheader.memsz,str);
// serial_print(str);
// serial_print("\n");
// char* ptr=alloc_memory(((pheader.memsz)/4096)+1);
// memset(ptr,0,pheader.memsz);
// if (pheader.filesz>0) {
// 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() {

Binary file not shown.

View File

@ -9,13 +9,11 @@
#include "../tasking.h"
#include "interrupt.h"
#include "address_spaces.h"
#include "mailboxes.h"
#include <mailboxes.h>
#include <string.h>
#include <stdint.h>
#include "serial.h"
#include <sys/types.h>
#include <sys/syscalls.h>
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;
}

View File

@ -1,120 +0,0 @@
#include "mailboxes.h"
#include "kmalloc.h"
#include <string.h>
#include <stdint.h>
#include <mailboxes.h>
#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_sz<mailbox.msg_store[mailbox.rd].size) {
recv_msg->size=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<next_box;i++) {
if (strcmp(mailboxes[i].name,name)==0) {
return i;
}
}
return 0;
}

View File

@ -1,13 +0,0 @@
#ifndef KERNEL_MAILBOXES_H
#define KERNEL_MAILBOXES_H
#include <stdint.h>
#include <mailboxes.h>
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

8
kernel/rpc.c Normal file
View File

@ -0,0 +1,8 @@
#include "cpu/tasking.h"
#include <string.h>
#include "rpc.h"
void rpc_init_struct(TaskRPCStruct* info) {
info->pendingrpc = 0;
info->callingpid = 0;
}

17
kernel/rpc.h Normal file
View File

@ -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

View File

@ -1,7 +1,12 @@
#include <sys/syscalls.h>
#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;

View File

@ -1,7 +1,12 @@
#include <sys/syscalls.h>
#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));
}

View File

@ -1,35 +0,0 @@
#include <stdint.h>
#include <mailboxes.h>
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;
}

View File

@ -1,9 +1,13 @@
#include <stdint.h>
#include <sys/syscalls.h>
#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;

View File

@ -1,4 +1,3 @@
#include <mailboxes.h>
#include <string.h>
#include <stdlib.h>
#include <ipc/vfs.h>
@ -7,447 +6,447 @@
#include <dbg.h>
#include <limits.h>
#include <unistd.h>
#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");
// }

View File

@ -1,38 +1,35 @@
#include <stdint.h>
#include <tasking.h>
#include <sys/types.h>
#include <sys/syscalls.h>
#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));
}

BIN
pci/pci

Binary file not shown.

View File

@ -1,26 +0,0 @@
#ifndef MAILBOXES_H
#define MAILBOXES_H
#include <stdint.h>
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

View File

@ -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

View File

@ -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);