2005-04-21 16:53:53 +02:00
|
|
|
#ifndef TYPE_H
|
|
|
|
#define TYPE_H
|
|
|
|
|
2006-06-20 11:56:06 +02:00
|
|
|
#include <minix/com.h>
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
typedef _PROTOTYPE( void task_t, (void) );
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
/* Process table and system property related types. */
|
|
|
|
typedef int proc_nr_t; /* process table entry number */
|
|
|
|
typedef short sys_id_t; /* system process index */
|
|
|
|
typedef struct { /* bitmap for system indexes */
|
|
|
|
bitchunk_t chunk[BITMAP_CHUNKS(NR_SYS_PROCS)];
|
|
|
|
} sys_map_t;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-07-29 17:26:23 +02:00
|
|
|
struct boot_image {
|
2005-05-19 11:36:44 +02:00
|
|
|
proc_nr_t proc_nr; /* process number to use */
|
2005-04-21 16:53:53 +02:00
|
|
|
task_t *initial_pc; /* start function for tasks */
|
2005-06-30 17:55:19 +02:00
|
|
|
int flags; /* process flags */
|
2005-08-19 18:43:28 +02:00
|
|
|
unsigned char quantum; /* quantum (tick count) */
|
2005-04-21 16:53:53 +02:00
|
|
|
int priority; /* scheduling priority */
|
|
|
|
int stksize; /* stack size for tasks */
|
2005-08-04 21:23:03 +02:00
|
|
|
short trap_mask; /* allowed system call traps */
|
|
|
|
bitchunk_t ipc_to; /* send mask protection */
|
2006-06-20 11:56:06 +02:00
|
|
|
int *k_calls; /* kern. call protection */
|
|
|
|
int nr_k_calls;
|
2005-05-31 11:50:51 +02:00
|
|
|
char proc_name[P_NAME_LEN]; /* name in process table */
|
2006-06-20 11:56:06 +02:00
|
|
|
endpoint_t endpoint; /* endpoint number when started */
|
2005-04-21 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct memory {
|
|
|
|
phys_clicks base; /* start address of chunk */
|
|
|
|
phys_clicks size; /* size of memory chunk */
|
|
|
|
};
|
|
|
|
|
2005-05-31 16:43:04 +02:00
|
|
|
/* The kernel outputs diagnostic messages in a circular buffer. */
|
|
|
|
struct kmessages {
|
|
|
|
int km_next; /* next index to write */
|
|
|
|
int km_size; /* current size in buffer */
|
|
|
|
char km_buf[KMESS_BUF_SIZE]; /* buffer for messages */
|
|
|
|
};
|
|
|
|
|
2005-06-03 15:55:06 +02:00
|
|
|
struct randomness {
|
2005-07-18 17:40:24 +02:00
|
|
|
struct {
|
|
|
|
int r_next; /* next index to write */
|
|
|
|
int r_size; /* number of random elements */
|
2005-07-27 16:32:16 +02:00
|
|
|
unsigned short r_buf[RANDOM_ELEMENTS]; /* buffer for random info */
|
2005-07-18 17:40:24 +02:00
|
|
|
} bin[RANDOM_SOURCES];
|
2005-06-03 15:55:06 +02:00
|
|
|
};
|
2005-05-31 16:43:04 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#if (CHIP == INTEL)
|
|
|
|
typedef unsigned reg_t; /* machine register */
|
|
|
|
|
|
|
|
/* The stack frame layout is determined by the software, but for efficiency
|
|
|
|
* it is laid out so the assembly code to use it is as simple as possible.
|
|
|
|
* 80286 protected mode and all real modes use the same frame, built with
|
|
|
|
* 16-bit registers. Real mode lacks an automatic stack switch, so little
|
|
|
|
* is lost by using the 286 frame for it. The 386 frame differs only in
|
|
|
|
* having 32-bit registers and more segment registers. The same names are
|
|
|
|
* used for the larger registers to avoid differences in the code.
|
|
|
|
*/
|
|
|
|
struct stackframe_s { /* proc_ptr points here */
|
|
|
|
#if _WORD_SIZE == 4
|
|
|
|
u16_t gs; /* last item pushed by save */
|
|
|
|
u16_t fs; /* ^ */
|
|
|
|
#endif
|
|
|
|
u16_t es; /* | */
|
|
|
|
u16_t ds; /* | */
|
|
|
|
reg_t di; /* di through cx are not accessed in C */
|
|
|
|
reg_t si; /* order is to match pusha/popa */
|
|
|
|
reg_t fp; /* bp */
|
|
|
|
reg_t st; /* hole for another copy of sp */
|
|
|
|
reg_t bx; /* | */
|
|
|
|
reg_t dx; /* | */
|
|
|
|
reg_t cx; /* | */
|
|
|
|
reg_t retreg; /* ax and above are all pushed by save */
|
|
|
|
reg_t retadr; /* return address for assembly code save() */
|
|
|
|
reg_t pc; /* ^ last item pushed by interrupt */
|
|
|
|
reg_t cs; /* | */
|
|
|
|
reg_t psw; /* | */
|
|
|
|
reg_t sp; /* | */
|
|
|
|
reg_t ss; /* these are pushed by CPU during interrupt */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct segdesc_s { /* segment descriptor for protected mode */
|
|
|
|
u16_t limit_low;
|
|
|
|
u16_t base_low;
|
|
|
|
u8_t base_middle;
|
|
|
|
u8_t access; /* |P|DL|1|X|E|R|A| */
|
|
|
|
u8_t granularity; /* |G|X|0|A|LIMT| */
|
|
|
|
u8_t base_high;
|
|
|
|
};
|
|
|
|
|
2005-05-02 16:30:04 +02:00
|
|
|
typedef unsigned long irq_policy_t;
|
2005-07-29 14:44:42 +02:00
|
|
|
typedef unsigned long irq_id_t;
|
2005-05-02 16:30:04 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
typedef struct irq_hook {
|
2005-05-02 16:30:04 +02:00
|
|
|
struct irq_hook *next; /* next hook in chain */
|
|
|
|
int (*handler)(struct irq_hook *); /* interrupt handler */
|
|
|
|
int irq; /* IRQ vector number */
|
|
|
|
int id; /* id of this hook */
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
int proc_nr_e; /* (endpoint) NONE if not in use */
|
2005-07-29 14:44:42 +02:00
|
|
|
irq_id_t notify_id; /* id to return on interrupt */
|
2005-05-02 16:30:04 +02:00
|
|
|
irq_policy_t policy; /* bit mask for policy */
|
2005-04-21 16:53:53 +02:00
|
|
|
} irq_hook_t;
|
|
|
|
|
|
|
|
typedef int (*irq_handler_t)(struct irq_hook *);
|
|
|
|
|
|
|
|
#endif /* (CHIP == INTEL) */
|
|
|
|
|
|
|
|
#if (CHIP == M68000)
|
|
|
|
/* M68000 specific types go here. */
|
|
|
|
#endif /* (CHIP == M68000) */
|
|
|
|
|
|
|
|
#endif /* TYPE_H */
|