kernel: some boottime sanitychecks
[minix.git] / include / minix / type.h
blobdbcb23e1f58d31d8e54cc51124344e397b210d03
1 #ifndef _TYPE_H
2 #define _TYPE_H
3 #include <machine/multiboot.h>
5 #ifndef _MINIX_SYS_CONFIG_H
6 #include <minix/sys_config.h>
7 #endif
9 #ifndef _TYPES_H
10 #include <minix/types.h>
11 #endif
13 #include <stdint.h>
15 /* Type definitions. */
16 typedef unsigned int vir_clicks; /* virtual addr/length in clicks */
17 typedef unsigned long phys_bytes; /* physical addr/length in bytes */
18 typedef unsigned int phys_clicks; /* physical addr/length in clicks */
19 typedef int endpoint_t; /* process identifier */
20 typedef int32_t cp_grant_id_t; /* A grant ID. */
21 typedef long unsigned int vir_bytes; /* virtual addresses/lengths in bytes */
23 /* Structure for virtual copying by means of a vector with requests. */
24 struct vir_addr {
25 endpoint_t proc_nr_e; /* NONE for phys, otherwise process endpoint */
26 vir_bytes offset;
29 #define phys_cp_req vir_cp_req
30 struct vir_cp_req {
31 struct vir_addr src;
32 struct vir_addr dst;
33 phys_bytes count;
36 /* Structures for SYS_VUMAP. */
37 struct vumap_vir {
38 union {
39 cp_grant_id_t u_grant; /* grant identifier, for non-SELF endpoint */
40 vir_bytes u_addr; /* local virtual address, for SELF endpoint */
41 } vv_u;
42 size_t vv_size; /* size in bytes */
44 #define vv_grant vv_u.u_grant
45 #define vv_addr vv_u.u_addr
47 struct vumap_phys {
48 phys_bytes vp_addr; /* physical address */
49 size_t vp_size; /* size in bytes */
52 /* I/O vector structures used in protocols between services. */
53 typedef struct {
54 vir_bytes iov_addr; /* address of an I/O buffer */
55 vir_bytes iov_size; /* sizeof an I/O buffer */
56 } iovec_t;
58 typedef struct {
59 cp_grant_id_t iov_grant; /* grant ID of an I/O buffer */
60 vir_bytes iov_size; /* sizeof an I/O buffer */
61 } iovec_s_t;
63 /* PM passes the address of a structure of this type to KERNEL when
64 * sys_sigsend() is invoked as part of the signal catching mechanism.
65 * The structure contain all the information that KERNEL needs to build
66 * the signal stack.
68 struct sigmsg {
69 int sm_signo; /* signal number being caught */
70 unsigned long sm_mask; /* mask to restore when handler returns */
71 vir_bytes sm_sighandler; /* address of handler */
72 vir_bytes sm_sigreturn; /* address of _sigreturn in C library */
73 vir_bytes sm_stkptr; /* user stack pointer */
76 /* Load data accounted every this no. of seconds. */
77 #define _LOAD_UNIT_SECS 6 /* Changing this breaks ABI. */
79 /* Load data history is kept for this long. */
80 #define _LOAD_HISTORY_MINUTES 15 /* Changing this breaks ABI. */
81 #define _LOAD_HISTORY_SECONDS (60*_LOAD_HISTORY_MINUTES)
83 /* We need this many slots to store the load history. */
84 #define _LOAD_HISTORY (_LOAD_HISTORY_SECONDS/_LOAD_UNIT_SECS)
86 /* Runnable processes and other load-average information. */
87 struct loadinfo {
88 u16_t proc_load_history[_LOAD_HISTORY]; /* history of proc_s_cur */
89 u16_t proc_last_slot;
90 clock_t last_clock;
93 struct machine {
94 unsigned processors_count; /* how many cpus are available */
95 unsigned bsp_id; /* id of the bootstrap cpu */
96 int padding; /* used to be protected */
97 int apic_enabled; /* does the kernel use APIC or not? */
98 phys_bytes acpi_rsdp; /* where is the acpi RSDP */
101 struct io_range
103 unsigned ior_base; /* Lowest I/O port in range */
104 unsigned ior_limit; /* Highest I/O port in range */
107 struct minix_mem_range
109 phys_bytes mr_base; /* Lowest memory address in range */
110 phys_bytes mr_limit; /* Highest memory address in range */
113 #define PROC_NAME_LEN 16
115 /* List of boot-time processes set in kernel/table.c. */
116 struct boot_image {
117 int proc_nr; /* process number to use */
118 char proc_name[PROC_NAME_LEN]; /* name in process table */
119 endpoint_t endpoint; /* endpoint number when started */
120 phys_bytes start_addr; /* Where it's in memory */
121 phys_bytes len;
124 /* Memory chunks. */
125 struct memory {
126 phys_bytes base;
127 phys_bytes size;
130 #define STATICINIT(v, n) \
131 if(!(v)) { \
132 if(!((v) = alloc_contig(sizeof(*(v)) * (n), 0, NULL))) { \
133 panic("allocating " #v " failed: %d", n); \
137 /* The kernel outputs diagnostic messages in a circular buffer. */
138 struct kmessages {
139 int km_next; /* next index to write */
140 int km_size; /* current size in buffer */
141 char km_buf[_KMESS_BUF_SIZE]; /* buffer for messages */
142 char kmess_buf[80*25]; /* printable copy of message buffer */
143 int blpos; /* kmess_buf position */
146 #include <minix/config.h>
147 #include <machine/interrupt.h>
149 /* randomness struct: random sources after interrupts: */
150 #define RANDOM_SOURCES 16
151 #define RANDOM_ELEMENTS 64
153 typedef unsigned short rand_t;
155 struct k_randomness {
156 int random_elements, random_sources;
157 struct k_randomness_bin {
158 int r_next; /* next index to write */
159 int r_size; /* number of random elements */
160 rand_t r_buf[RANDOM_ELEMENTS]; /* buffer for random info */
161 } bin[RANDOM_SOURCES];
164 struct minix_kerninfo {
165 /* Binaries will depend on the offsets etc. in this
166 * structure, so it can't be changed willy-nilly. In
167 * other words, it is ABI-restricted.
169 #define KERNINFO_MAGIC 0xfc3b84bf
170 u32_t kerninfo_magic;
171 u32_t minix_feature_flags; /* features in minix kernel */
172 u32_t ki_flags; /* what is present in this struct */
173 u32_t flags_unused2;
174 u32_t flags_unused3;
175 u32_t flags_unused4;
176 struct kinfo *kinfo;
177 struct machine *machine;
178 struct kmessages *kmessages;
179 struct loadinfo *loadinfo;
180 struct minix_ipcvecs *minix_ipcvecs;
181 } __packed;
183 #define MINIX_KIF_IPCVECS (1L << 0)
185 #endif /* _TYPE_H */