MyOS Kernel
rpc.c File Reference
#include <sys/types.h>
#include <stddef.h>
#include "tasking.h"
#include "rpc.h"
#include "pmem.h"
#include "cpu/paging.h"
#include "cpu/arch_consts.h"
#include "kmalloc.h"
#include <string.h>
#include "cpu/serial.h"

Data Structures

struct  rpc_waiting_thread
 

Functions

static void mark_init (pid_t pid)
 
static void clear_init (pid_t pid)
 
static char is_init (pid_t pid)
 
void * kernel_rpc_call (pid_t pid, char *name, void *buf, size_t size)
 
void kernel_rpc_register_func (char *name, rpc_func code)
 
void kernel_rpc_deallocate_buf (void *buf, size_t size)
 
void kernel_rpc_return (void *buf, size_t size)
 
size_t kernel_get_num_rpc_funcs (pid_t pid)
 
void kernel_rpc_mark_as_init ()
 

Variables

rpc_func_infoprocess_funcs [32768] ={NULL}
 Pointers to a list of registered functions for each process.
 
size_t process_num_funcs [32768] ={0}
 The number of functions each process has registered.
 
char process_ready_bmap [32768/8] ={0}
 A bitmap of processes that have completed RPC init.
 
rpc_waiting_threadwaiting_thread_list =NULL
 A linked list of threads waiting for a process to finish RPC init.
 

Function Documentation

◆ clear_init()

static void clear_init ( pid_t  pid)
static

Mark a process as not ready to accept RPC calls

Parameters
pidThe pid to mark

◆ is_init()

static char is_init ( pid_t  pid)
static

Check if a process is ready to accept RPC calls

Parameters
pidThe pid to check
Returns
whether the process is ready

◆ kernel_get_num_rpc_funcs()

size_t kernel_get_num_rpc_funcs ( pid_t  pid)

Get the number of RPC functions a process has registers

Parameters
pidThe PID of the process
Returns
the number of RPC functions the process has registered

◆ kernel_rpc_call()

void* kernel_rpc_call ( pid_t  pid,
char *  name,
void *  buf,
size_t  size 
)

Call an RPC function

Parameters
pidThe PID of the process with the RPC function
nameThe name of the function to call
bufThe argument buffer to provide
sizeThe size of the argument buffer
Returns
the return buffer of the RPC functiom

◆ kernel_rpc_deallocate_buf()

void kernel_rpc_deallocate_buf ( void *  buf,
size_t  size 
)

Deallocate an RPC return buffer

Parameters
bufThe buffer to deallocate
sizeThe size of the buffer to deallocate

◆ kernel_rpc_mark_as_init()

void kernel_rpc_mark_as_init ( )

Mark the current process as ready to accept RPC calls

◆ kernel_rpc_register_func()

void kernel_rpc_register_func ( char *  name,
rpc_func  code 
)

Register an RPC function

Parameters
nameThe name of the function
codeThe code of the function

◆ kernel_rpc_return()

void kernel_rpc_return ( void *  buf,
size_t  size 
)

Set the RPC return buffer for the calling thread & unblock the calling thread

Parameters
bufThe return buffer
sizeThe size of the return buffer
Note
This function must only be called from an RPC thread

◆ mark_init()

static void mark_init ( pid_t  pid)
static

Mark a process as ready to accept RPC calls

Parameters
pidThe pid to mark