Modestus Moon OS  R4
CS 450 project
mpx_supt.c File Reference
#include <core/mpx_supt.h>
#include <mem/heap.h>
#include <core/pcb.h>
Include dependency graph for mpx_supt.c:

Go to the source code of this file.

Functions

int sys_req (int op_code)
 
void mpx_init (int cur_mod)
 
void sys_set_malloc (void *(*func)(size_t))
 
void sys_set_free (int(*func)(void *))
 
void * sys_alloc_mem (u32int size)
 
int sys_free_mem (void *ptr)
 
void idle ()
 
uint32_tsys_call (processContext_t *context)
 sys_call More...
 

Variables

param params
 
int current_module = MODULE_R5
 
void *(* student_malloc )(size_t)
 
int(* student_free )(void *)
 
processContext_tcallerContext
 

Function Documentation

void idle ( )

Definition at line 49 of file mpx_supt.c.

References EXIT, IDLE, readyQueue, serial_println(), and sys_req().

Referenced by kmain().

50 {
51  serial_println("\r\n\033[38;2;255;0;255mIn Idle Process\033[38;2;255;255;255m\r\n");
52  do {
53  sys_req(IDLE);
54  serial_println("\r\n\033[38;2;255;0;255mIn Idle Process\033[38;2;255;255;255m\r\n");
55  }while(readyQueue.head.next != &(readyQueue.tail));
56  serial_println("No More ready processes, IDLE is exiting");
57  sys_req(EXIT);
58 }
linkedList_t readyQueue
Definition: pcb.c:3
#define EXIT
Definition: mpx_supt.h:6
int serial_println(const char *msg)
Definition: serial.c:44
int sys_req(int op_code)
Definition: mpx_supt.c:11
#define IDLE
Definition: mpx_supt.h:7
void mpx_init ( int  cur_mod)

Definition at line 18 of file mpx_supt.c.

References current_module.

19 {
20  current_module = cur_mod;
21 }
int current_module
Definition: mpx_supt.c:7
void* sys_alloc_mem ( u32int  size)

Definition at line 33 of file mpx_supt.c.

References current_module, kmalloc(), and MODULE_R5.

Referenced by allocatePCB(), and makeNewNode().

34 {
36  return (void *) kmalloc(size);
37  else
38  return (void *) (*student_malloc)(size);
39 }
u32int kmalloc(u32int size)
Definition: heap.c:52
#define MODULE_R5
Definition: mpx_supt.h:15
int current_module
Definition: mpx_supt.c:7
uint32_t* sys_call ( processContext_t context)

sys_call

Parameters
context
Returns

Definition at line 62 of file mpx_supt.c.

References callerContext, currentOperatingProcess, EXIT, freePCB(), IDLE, insertPCB(), kpanic(), param::op_code, READY, readyQueue, removePCB(), RUNNING, and SUCCESS.

63 {
65  {
66  if(params.op_code == IDLE)
67  {
68  currentOperatingProcess->stackTop = (processStack_t*)context;
69  currentOperatingProcess->processState = READY;
71  }
72  else if(params.op_code == EXIT)
73  {
75  }
76  }
77  else
78  {
79  callerContext = context;
80  }
81  if(readyQueue.head.next != &readyQueue.tail)
82  {
83  if(removePCB(currentOperatingProcess = (pcb_t*)readyQueue.head.next->data) == SUCCESS)
84  {
85  currentOperatingProcess->processState = RUNNING;
86  return (uint32_t*)currentOperatingProcess->stackTop;
87  }
88  else
89  {
90  kpanic("Could Not remove COP from ready Queue!!!!!");
91  }
92  }
93 
94  return (uint32_t*)callerContext;
95 
96 }
Definition: pcb.h:47
Definition: pcb.h:47
linkedList_t readyQueue
Definition: pcb.c:3
void kpanic(const char *msg)
Definition: system.c:24
pcb_t * currentOperatingProcess
Definition: pcb.c:9
#define EXIT
Definition: mpx_supt.h:6
Definition: pcb.h:38
typedef for pcb_t struct
void insertPCB(pcb_t *pcbToInsert)
insertPCB insert the PCB into the queue represented by the process state, following each queue&#39;s rule...
Definition: pcb.c:132
e_PCB_ERROR_CODE_t freePCB(pcb_t *pcbToFree)
freePCB free all associated memory with the PCB, including the stack and other pointers ...
Definition: pcb.c:32
int op_code
Definition: mpx_supt.h:19
uint8_t processStack_t
processStack_t a pointer to someplace in a process&#39;s stack
Definition: pcb.h:102
e_PCB_ERROR_CODE_t removePCB(pcb_t *pcbToRemove)
removePCB remove the input PCB from its associated queue
Definition: pcb.c:162
processContext_t * callerContext
Definition: mpx_supt.c:60
unsigned long uint32_t
Definition: system.h:31
param params
Definition: mpx_supt.c:6
#define IDLE
Definition: mpx_supt.h:7
int sys_free_mem ( void *  ptr)

Definition at line 41 of file mpx_supt.c.

References current_module, MODULE_R5, and student_free.

42 {
44  return (*student_free)(ptr);
45  // otherwise we don't free anything
46  return -1;
47 }
#define MODULE_R5
Definition: mpx_supt.h:15
int current_module
Definition: mpx_supt.c:7
int(* student_free)(void *)
Definition: mpx_supt.c:9
int sys_req ( int  op_code)

Definition at line 11 of file mpx_supt.c.

References param::op_code.

Referenced by idle(), init_commhand(), kmain(), proc1(), proc2(), proc3(), proc4(), proc5(), and shutdownFunc().

12 {
13  params.op_code = op_code;
14  asm volatile ("int $60");
15  return 0;
16 }
int op_code
Definition: mpx_supt.h:19
param params
Definition: mpx_supt.c:6
void sys_set_free ( int(*)(void *)  func)

Definition at line 28 of file mpx_supt.c.

References student_free.

Referenced by kmain().

29 {
30  student_free = func;
31 }
int(* student_free)(void *)
Definition: mpx_supt.c:9
void sys_set_malloc ( void *(*)(size_t func)

Definition at line 23 of file mpx_supt.c.

References student_malloc.

Referenced by kmain().

24 {
25  student_malloc = func;
26 }
void *(* student_malloc)(size_t)
Definition: mpx_supt.c:8

Variable Documentation

processContext_t* callerContext

Definition at line 60 of file mpx_supt.c.

Referenced by sys_call().

int current_module = MODULE_R5

Definition at line 7 of file mpx_supt.c.

Referenced by mpx_init(), sys_alloc_mem(), and sys_free_mem().

param params

Definition at line 6 of file mpx_supt.c.

int(* student_free) (void *)

Definition at line 9 of file mpx_supt.c.

Referenced by sys_free_mem(), and sys_set_free().

void*(* student_malloc) (size_t)

Definition at line 8 of file mpx_supt.c.

Referenced by sys_set_malloc().