Mailboxes now have names
This commit is contained in:
parent
1522fed9a8
commit
9a89873c8b
@ -116,8 +116,8 @@ void process_vfs_msg(vfs_message* vfs_msg) {
|
||||
|
||||
|
||||
int main() {
|
||||
vfs_box=mailbox_new(16);
|
||||
devfs_box=mailbox_new(16);
|
||||
vfs_box=mailbox_new(16,"devfs_vfs");
|
||||
devfs_box=mailbox_new(16,"devfs_devfs");
|
||||
register_fs("devfs",vfs_box);
|
||||
dev_names=malloc(sizeof(char*)*32);
|
||||
dev_mboxes=malloc(sizeof(uint32_t)*32);
|
||||
|
@ -228,7 +228,7 @@ void isr_handler(registers_t r) {
|
||||
} else if (r.eax==13) {
|
||||
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);
|
||||
r.ebx=kernel_mailbox_new((uint16_t)r.ebx,(char*)r.ecx);
|
||||
} else if (r.eax==15) {
|
||||
tasking_yieldToPID(r.ebx);
|
||||
} else if (r.eax==16) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
Mailbox* mailboxes=(Mailbox*)0xF6400000;
|
||||
uint32_t next_box=1;
|
||||
|
||||
uint32_t kernel_mailbox_new(uint16_t size) {
|
||||
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;
|
||||
@ -18,7 +18,11 @@ uint32_t kernel_mailbox_new(uint16_t size) {
|
||||
mailboxes[next_box].wr=0;
|
||||
mailboxes[next_box].size=size;
|
||||
mailboxes[next_box].msg_store=kmalloc(sizeof(Message)*size);
|
||||
serial_printf("PID %d created mailbox %d\n",getPID(),next_box);
|
||||
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;
|
||||
}
|
||||
@ -29,7 +33,7 @@ void kernel_mailbox_free(uint32_t box) {
|
||||
|
||||
void kernel_mailbox_send_msg(Message* user_msg) {
|
||||
if (user_msg->to==0) {
|
||||
serial_printf("Box %d attempted to send to box 0!\n",user_msg->from);
|
||||
serial_printf("Box %s attempted to send to box 0!\n",mailboxes[user_msg->from].name);
|
||||
return;
|
||||
}
|
||||
Mailbox mailbox=mailboxes[user_msg->to];
|
||||
@ -50,7 +54,7 @@ void kernel_mailbox_send_msg(Message* user_msg) {
|
||||
}
|
||||
}
|
||||
mailboxes[user_msg->to]=mailbox;
|
||||
serial_printf("Message sent from box %d to box %d\n",user_msg->from,user_msg->to);
|
||||
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) {
|
||||
@ -58,7 +62,7 @@ void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz)
|
||||
if (mailbox.msg_store[mailbox.rd].size==0) {
|
||||
recv_msg->size=0;
|
||||
recv_msg->from=0;
|
||||
serial_printf("Box %d attempted to get a message, but there were none.\n",box);
|
||||
serial_printf("Box %s attempted to get a message, but there were none.\n",mailboxes[box].name);
|
||||
mailboxes[box]=mailbox;
|
||||
return;
|
||||
}
|
||||
@ -68,8 +72,7 @@ void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz)
|
||||
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 %d attempted to get the message from box %d, but the buffer was too small.\n",box,mailbox.msg_store[mailbox.rd].from);
|
||||
serial_printf("The message size is %d, and the buffer size is %d.\n",mailbox.msg_store[mailbox.rd].size,buffer_sz);
|
||||
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);
|
||||
mailboxes[box]=mailbox;
|
||||
return;
|
||||
}
|
||||
@ -84,6 +87,6 @@ void kernel_mailbox_get_msg(uint32_t box, Message* recv_msg, uint32_t buffer_sz)
|
||||
if (mailbox.rd>mailbox.wr && !(orig_rd>mailbox.wr)) {
|
||||
mailbox.rd=mailbox.wr;
|
||||
}
|
||||
serial_printf("Box %d got a message from box %d.\n",box,recv_msg->from);
|
||||
serial_printf("Box %s got a message from box %s.\n",mailboxes[box].name,mailboxes[recv_msg->from].name);
|
||||
mailboxes[box]=mailbox;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <mailboxes.h>
|
||||
|
||||
uint32_t kernel_mailbox_new(uint16_t size);
|
||||
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);
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include <stdint.h>
|
||||
#include <mailboxes.h>
|
||||
|
||||
uint32_t mailbox_new(uint16_t size) {
|
||||
uint32_t mailbox_new(uint16_t size,char* name) {
|
||||
uint32_t box;
|
||||
asm volatile(" \
|
||||
mov $14, %%eax; \
|
||||
int $80; \
|
||||
":"=b"(box):"b"(size));
|
||||
":"=b"(box):"b"(size),"c"(name));
|
||||
return box;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <tasking.h>
|
||||
#include <dbg.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#define VFS_MBOX 3
|
||||
#define VFS_PID 2
|
||||
|
||||
@ -17,7 +18,12 @@ FILE* __stdio_stderr;
|
||||
|
||||
|
||||
void __stdio_init() {
|
||||
box=mailbox_new(16);
|
||||
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*));
|
||||
|
@ -15,9 +15,10 @@ typedef struct {
|
||||
uint32_t wr;
|
||||
uint16_t size;
|
||||
Message* msg_store;
|
||||
char name[20];
|
||||
} Mailbox;
|
||||
|
||||
uint32_t mailbox_new(uint16_t size);
|
||||
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);
|
||||
|
||||
|
@ -282,7 +282,7 @@ void vfs_mount(vfs_message* vfs_msg, uint32_t from) {
|
||||
|
||||
int main() {
|
||||
init_vfs();
|
||||
box=mailbox_new(16);
|
||||
box=mailbox_new(16,"vfs");
|
||||
yield();
|
||||
while (1) {
|
||||
Message msg;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#define DEVFS_PID 3
|
||||
|
||||
int main() {
|
||||
uint32_t box=mailbox_new(16);
|
||||
uint32_t box=mailbox_new(16,"vga");
|
||||
text_fb_info info;
|
||||
info.address=map_phys((void*)0xB8000,10);
|
||||
info.width=80;
|
||||
|
Loading…
x
Reference in New Issue
Block a user