source: branches/minix3-book/kernel/type.h@ 4

Last change on this file since 4 was 4, checked in by Mattia Monga, 13 years ago

Importazione sorgenti libro

File size: 3.8 KB
Line 
1#ifndef TYPE_H
2#define TYPE_H
3
4typedef _PROTOTYPE( void task_t, (void) );
5
6/* Process table and system property related types. */
7typedef int proc_nr_t; /* process table entry number */
8typedef short sys_id_t; /* system process index */
9typedef struct { /* bitmap for system indexes */
10 bitchunk_t chunk[BITMAP_CHUNKS(NR_SYS_PROCS)];
11} sys_map_t;
12
13struct boot_image {
14 proc_nr_t proc_nr; /* process number to use */
15 task_t *initial_pc; /* start function for tasks */
16 int flags; /* process flags */
17 unsigned char quantum; /* quantum (tick count) */
18 int priority; /* scheduling priority */
19 int stksize; /* stack size for tasks */
20 short trap_mask; /* allowed system call traps */
21 bitchunk_t ipc_to; /* send mask protection */
22 long call_mask; /* system call protection */
23 char proc_name[P_NAME_LEN]; /* name in process table */
24};
25
26struct memory {
27 phys_clicks base; /* start address of chunk */
28 phys_clicks size; /* size of memory chunk */
29};
30
31/* The kernel outputs diagnostic messages in a circular buffer. */
32struct kmessages {
33 int km_next; /* next index to write */
34 int km_size; /* current size in buffer */
35 char km_buf[KMESS_BUF_SIZE]; /* buffer for messages */
36};
37
38struct randomness {
39 struct {
40 int r_next; /* next index to write */
41 int r_size; /* number of random elements */
42 unsigned short r_buf[RANDOM_ELEMENTS]; /* buffer for random info */
43 } bin[RANDOM_SOURCES];
44};
45
46#if (CHIP == INTEL)
47typedef unsigned reg_t; /* machine register */
48
49/* The stack frame layout is determined by the software, but for efficiency
50 * it is laid out so the assembly code to use it is as simple as possible.
51 * 80286 protected mode and all real modes use the same frame, built with
52 * 16-bit registers. Real mode lacks an automatic stack switch, so little
53 * is lost by using the 286 frame for it. The 386 frame differs only in
54 * having 32-bit registers and more segment registers. The same names are
55 * used for the larger registers to avoid differences in the code.
56 */
57struct stackframe_s { /* proc_ptr points here */
58#if _WORD_SIZE == 4
59 u16_t gs; /* last item pushed by save */
60 u16_t fs; /* ^ */
61#endif
62 u16_t es; /* | */
63 u16_t ds; /* | */
64 reg_t di; /* di through cx are not accessed in C */
65 reg_t si; /* order is to match pusha/popa */
66 reg_t fp; /* bp */
67 reg_t st; /* hole for another copy of sp */
68 reg_t bx; /* | */
69 reg_t dx; /* | */
70 reg_t cx; /* | */
71 reg_t retreg; /* ax and above are all pushed by save */
72 reg_t retadr; /* return address for assembly code save() */
73 reg_t pc; /* ^ last item pushed by interrupt */
74 reg_t cs; /* | */
75 reg_t psw; /* | */
76 reg_t sp; /* | */
77 reg_t ss; /* these are pushed by CPU during interrupt */
78};
79
80struct segdesc_s { /* segment descriptor for protected mode */
81 u16_t limit_low;
82 u16_t base_low;
83 u8_t base_middle;
84 u8_t access; /* |P|DL|1|X|E|R|A| */
85 u8_t granularity; /* |G|X|0|A|LIMT| */
86 u8_t base_high;
87};
88
89typedef unsigned long irq_policy_t;
90typedef unsigned long irq_id_t;
91
92typedef struct irq_hook {
93 struct irq_hook *next; /* next hook in chain */
94 int (*handler)(struct irq_hook *); /* interrupt handler */
95 int irq; /* IRQ vector number */
96 int id; /* id of this hook */
97 int proc_nr; /* NONE if not in use */
98 irq_id_t notify_id; /* id to return on interrupt */
99 irq_policy_t policy; /* bit mask for policy */
100} irq_hook_t;
101
102typedef int (*irq_handler_t)(struct irq_hook *);
103
104#endif /* (CHIP == INTEL) */
105
106#if (CHIP == M68000)
107/* M68000 specific types go here. */
108#endif /* (CHIP == M68000) */
109
110#endif /* TYPE_H */
Note: See TracBrowser for help on using the repository browser.