3.1.7 branch.
[minix.git] / kernel / table.c
blobf422a6da2b6d7f5166cc257cfd711c4282cd98f9
1 /* The object file of "table.c" contains most kernel data. Variables that
2 * are declared in the *.h files appear with EXTERN in front of them, as in
4 * EXTERN int x;
6 * Normally EXTERN is defined as extern, so when they are included in another
7 * file, no storage is allocated. If EXTERN were not present, but just say,
9 * int x;
11 * then including this file in several source files would cause 'x' to be
12 * declared several times. While some linkers accept this, others do not,
13 * so they are declared extern when included normally. However, it must be
14 * declared for real somewhere. That is done here, by redefining EXTERN as
15 * the null string, so that inclusion of all *.h files in table.c actually
16 * generates storage for them.
18 * Various variables could not be declared EXTERN, but are declared PUBLIC
19 * or PRIVATE. The reason for this is that extern variables cannot have a
20 * default initialization. If such variables are shared, they must also be
21 * declared in one of the *.h files without the initialization. Examples
22 * include 'boot_image' (this file) and 'idt' and 'gdt' (protect.c).
24 * Changes:
25 * Nov 22, 2009 rewrite of privilege management (Cristiano Giuffrida)
26 * Aug 02, 2005 set privileges and minimal boot image (Jorrit N. Herder)
27 * Oct 17, 2004 updated above and tasktab comments (Jorrit N. Herder)
28 * May 01, 2004 changed struct for system image (Jorrit N. Herder)
30 #define _TABLE
32 #include "kernel.h"
33 #include "proc.h"
34 #include "ipc.h"
35 #include <minix/com.h>
37 /* Define stack sizes for the kernel tasks included in the system image. */
38 #define NO_STACK 0
39 #define SMALL_STACK (1024 * sizeof(char *))
40 #define IDL_S SMALL_STACK /* 3 intr, 3 temps, 4 db for Intel */
41 #define HRD_S NO_STACK /* dummy task, uses kernel stack */
42 #define TSK_S SMALL_STACK /* system and clock task */
44 /* Stack space for all the task stacks. Declared as (char *) to align it. */
45 #define TOT_STACK_SPACE (IDL_S + HRD_S + (2 * TSK_S))
46 PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
48 /* Define boot process flags. */
49 #define BVM_F (PROC_FULLVM) /* boot processes with VM */
51 /* The system image table lists all programs that are part of the boot image.
52 * The order of the entries here MUST agree with the order of the programs
53 * in the boot image and all kernel tasks must come first.
54 * The order of the entries here matches the priority NOTIFY messages are
55 * delivered to a given process. NOTIFY messages are always delivered with
56 * the highest priority. DS must be the first system process in the list to
57 * allow reliable asynchronous publishing of system events. RS comes right after
58 * to prioritize ping messages periodically delivered to system processes.
60 * Each entry provides the process number, flags, quantum size, scheduling
61 * queue, and a name for the process table. The initial program counter and
62 * stack size is also provided for kernel tasks.
64 * Note: the quantum size must be positive in all cases!
67 PUBLIC struct boot_image image[] = {
68 /* process nr, flags, ms, queue, stack, name */
69 {IDLE, 0, 0, 0, IDL_S, "idle" },
70 {CLOCK, 0, 0, 0, IDL_S, "clock" },
71 {SYSTEM, 0, 0, 0, IDL_S, "system"},
72 {HARDWARE, 0, 0, 0, HRD_S, "kernel"},
74 {DS_PROC_NR, BVM_F, 50, 4, 0, "ds" },
75 {RS_PROC_NR, 0, 50, 4, 0, "rs" },
77 {PM_PROC_NR, 0,500, 4, 0, "pm" },
78 {SCHED_PROC_NR, 0,500, 4, 0, "sched" },
79 {FS_PROC_NR, 0,500, 5, 0, "vfs" },
80 {MEM_PROC_NR, BVM_F, 50, 3, 0, "memory"},
81 {LOG_PROC_NR, BVM_F, 50, 2, 0, "log" },
82 {TTY_PROC_NR, BVM_F, 50, 1, 0, "tty" },
83 {MFS_PROC_NR, BVM_F,500, 5, 0, "mfs" },
84 {VM_PROC_NR, 0,500, 2, 0, "vm" },
85 {PFS_PROC_NR, BVM_F,500, 5, 0, "pfs" },
86 {INIT_PROC_NR, BVM_F,200, USER_Q, 0, "init" },
89 /* Verify the size of the system image table at compile time. Also verify that
90 * the first chunk of the ipc mask has enough bits to accommodate the processes
91 * in the image.
92 * If a problem is detected, the size of the 'dummy' array will be negative,
93 * causing a compile time error. Note that no space is actually allocated
94 * because 'dummy' is declared extern.
96 extern int dummy[(NR_BOOT_PROCS==sizeof(image)/
97 sizeof(struct boot_image))?1:-1];
98 extern int dummy[(BITCHUNK_BITS > NR_BOOT_PROCS - 1) ? 1 : -1];