-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.h
126 lines (100 loc) · 2.69 KB
/
header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef HEADER_H
#define HEADER_H
#include <math.h>
#define NPROC 9
#define SSIZE 1024
/******* PROC status ********/
#define FREE 0
#define READY 1
#define RUNNING 2
#define STOPPED 3
#define SLEEP 4
#define ZOMBIE 5
typedef struct proc{
struct proc *next;
int *ksp;
int pid; // add pid for identify the proc
int status; // status = FREE|READY|RUNNING|SLEEP|ZOMBIE
int ppid; // parent pid
struct proc *parent;
int priority;
int event;
int exitCode;
int kstack[SSIZE]; // per proc stack area
}PROC;
PROC proc[NPROC], *running, *freeList, *readyQueue, *sleepList;
int procSize = sizeof(PROC);
int nproc = 0;
extern int color;
/******Conner's Additions Below***********/
// additions from io.h from lab 2
typedef unsigned char u8;
typedef unsigned int u16;
typedef unsigned long u32;
#define GREEN 10 // color byte for putc()
#define CYAN 11
#define RED 12
#define MAG 13
#define YELLOW 14
struct partition { // Partition table entry in MBR
u8 drive; // 0x80 - active
u8 head; // starting head
u8 sector; // starting sector
u8 cylinder; // starting cylinder
u8 type; // partition type
u8 end_head; // end head
u8 end_sector; // end sector
u8 end_cylinder; // end cylinder
u32 start_sector; // starting sector counting from 0
u32 nr_sectors; // nr of sectors in partition
};
struct dap{ // DAP for extended INT 13-42
u8 len; // dap length=0x10 (16 bytes)
u8 zero; // must be 0
u16 nsector; // number of sectors to read: 1 to 127
u16 addr; // memory address = (segment:addr)
u16 segment;
u32 s1; // low 4 bytes of sector#
u32 s2; // high 4 bytes of sector#
};
struct dap dap, *dp; // global dap struct
// io globals
int BASE = 10;
int *FP;
char *table = "0123456789ABCDEF";
#define BOOTSEG 0x9000
char mbr[512];
char ans[64];
/******function headers*******/
// t.c
int init();
int scheduler();
PROC *kfork();
int body(void);
// commands.c
do_tswitch();
do_kfork();
do_exit();
do_sleep();
do_wake();
do_wait();
// kernel.c
int ksleep(int event);
int kwakeup(int event);
int kexit(int exitvalue);
int kwait(int *status);
//io.c
int rpu(u32 x);
int rpu16(u16 x);
int printu(u32 x);
int printd(int x);
int printo(u32 x);
int printx(u32 x);
void printf(char *fmt, ...);
int prints(char *s);
strcmp();
int gets(char s[64]);
int strtoint(char *str);
int isDigit(char c);
int power(int x, int y);
#endif