2005-04-21 16:53:53 +02:00
|
|
|
/* The object file of "table.c" contains most kernel data. Variables that
|
|
|
|
* are declared in the *.h files appear with EXTERN in front of them, as in
|
|
|
|
*
|
|
|
|
* EXTERN int x;
|
|
|
|
*
|
|
|
|
* Normally EXTERN is defined as extern, so when they are included in another
|
|
|
|
* file, no storage is allocated. If EXTERN were not present, but just say,
|
|
|
|
*
|
|
|
|
* int x;
|
|
|
|
*
|
|
|
|
* then including this file in several source files would cause 'x' to be
|
|
|
|
* declared several times. While some linkers accept this, others do not,
|
|
|
|
* so they are declared extern when included normally. However, it must be
|
|
|
|
* declared for real somewhere. That is done here, by redefining EXTERN as
|
|
|
|
* the null string, so that inclusion of all *.h files in table.c actually
|
|
|
|
* generates storage for them.
|
|
|
|
*
|
|
|
|
* Various variables could not be declared EXTERN, but are declared PUBLIC
|
|
|
|
* or PRIVATE. The reason for this is that extern variables cannot have a
|
|
|
|
* default initialization. If such variables are shared, they must also be
|
|
|
|
* declared in one of the *.h files without the initialization. Examples
|
2005-07-29 17:26:23 +02:00
|
|
|
* include 'boot_image' (this file) and 'idt' and 'gdt' (protect.c).
|
2005-04-21 16:53:53 +02:00
|
|
|
*
|
|
|
|
* Changes:
|
2009-12-11 01:08:19 +01:00
|
|
|
* Nov 22, 2009 rewrite of privilege management (Cristiano Giuffrida)
|
2005-08-04 21:23:03 +02:00
|
|
|
* Aug 02, 2005 set privileges and minimal boot image (Jorrit N. Herder)
|
2005-04-21 16:53:53 +02:00
|
|
|
* Oct 17, 2004 updated above and tasktab comments (Jorrit N. Herder)
|
2005-07-21 20:36:40 +02:00
|
|
|
* May 01, 2004 changed struct for system image (Jorrit N. Herder)
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
#define _TABLE
|
|
|
|
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "proc.h"
|
2005-05-31 11:50:51 +02:00
|
|
|
#include "ipc.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <minix/com.h>
|
|
|
|
|
2005-08-02 17:28:09 +02:00
|
|
|
/* Define stack sizes for the kernel tasks included in the system image. */
|
2005-04-21 16:53:53 +02:00
|
|
|
#define NO_STACK 0
|
Primary goal for these changes is:
- no longer have kernel have its own page table that is loaded
on every kernel entry (trap, interrupt, exception). the primary
purpose is to reduce the number of required reloads.
Result:
- kernel can only access memory of process that was running when
kernel was entered
- kernel must be mapped into every process page table, so traps to
kernel keep working
Problem:
- kernel must often access memory of arbitrary processes (e.g. send
arbitrary processes messages); this can't happen directly any more;
usually because that process' page table isn't loaded at all, sometimes
because that memory isn't mapped in at all, sometimes because it isn't
mapped in read-write.
So:
- kernel must be able to map in memory of any process, in its own
address space.
Implementation:
- VM and kernel share a range of memory in which addresses of
all page tables of all processes are available. This has two purposes:
. Kernel has to know what data to copy in order to map in a range
. Kernel has to know where to write the data in order to map it in
That last point is because kernel has to write in the currently loaded
page table.
- Processes and kernel are separated through segments; kernel segments
haven't changed.
- The kernel keeps the process whose page table is currently loaded
in 'ptproc.'
- If it wants to map in a range of memory, it writes the value of the
page directory entry for that range into the page directory entry
in the currently loaded map. There is a slot reserved for such
purposes. The kernel can then access this memory directly.
- In order to do this, its segment has been increased (and the
segments of processes start where it ends).
- In the pagefault handler, detect if the kernel is doing
'trappable' memory access (i.e. a pagefault isn't a fatal
error) and if so,
- set the saved instruction pointer to phys_copy_fault,
breaking out of phys_copy
- set the saved eax register to the address of the page
fault, both for sanity checking and for checking in
which of the two ranges that phys_copy was called
with the fault occured
- Some boot-time processes do not have their own page table,
and are mapped in with the kernel, and separated with
segments. The kernel detects this using HASPT. If such a
process has to be scheduled, any page table will work and
no page table switch is done.
Major changes in kernel are
- When accessing user processes memory, kernel no longer
explicitly checks before it does so if that memory is OK.
It simply makes the mapping (if necessary), tries to do the
operation, and traps the pagefault if that memory isn't present;
if that happens, the copy function returns EFAULT.
So all of the CHECKRANGE_OR_SUSPEND macros are gone.
- Kernel no longer has to copy/read and parse page tables.
- A message copying optimisation: when messages are copied, and
the recipient isn't mapped in, they are copied into a buffer
in the kernel. This is done in QueueMess. The next time
the recipient is scheduled, this message is copied into
its memory. This happens in schedcheck().
This eliminates the mapping/copying step for messages, and makes
it easier to deliver messages. This eliminates soft_notify.
- Kernel no longer creates a page table at all, so the vm_setbuf
and pagetable writing in memory.c is gone.
Minor changes in kernel are
- ipc_stats thrown out, wasn't used
- misc flags all renamed to MF_*
- NOREC_* macros to enter and leave functions that should not
be called recursively; just sanity checks really
- code to fully decode segment selectors and descriptors
to print on exceptions
- lots of vmassert()s added, only executed if DEBUG_VMASSERT is 1
2009-09-21 16:31:52 +02:00
|
|
|
#define SMALL_STACK (1024 * sizeof(char *))
|
2005-08-04 11:26:36 +02:00
|
|
|
#define IDL_S SMALL_STACK /* 3 intr, 3 temps, 4 db for Intel */
|
|
|
|
#define HRD_S NO_STACK /* dummy task, uses kernel stack */
|
|
|
|
#define TSK_S SMALL_STACK /* system and clock task */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Stack space for all the task stacks. Declared as (char *) to align it. */
|
2005-08-04 11:26:36 +02:00
|
|
|
#define TOT_STACK_SPACE (IDL_S + HRD_S + (2 * TSK_S))
|
2005-04-21 16:53:53 +02:00
|
|
|
PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
|
2005-08-02 17:28:09 +02:00
|
|
|
|
2009-12-11 01:08:19 +01:00
|
|
|
/* Define boot process flags. */
|
|
|
|
#define BVM_F (PROC_FULLVM) /* boot processes with VM */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* The system image table lists all programs that are part of the boot image.
|
|
|
|
* The order of the entries here MUST agree with the order of the programs
|
2009-12-11 01:08:19 +01:00
|
|
|
* in the boot image and all kernel tasks must come first.
|
2010-03-23 00:44:55 +01:00
|
|
|
* The order of the entries here matches the priority NOTIFY messages are
|
|
|
|
* delivered to a given process. NOTIFY messages are always delivered with
|
|
|
|
* the highest priority. DS must be the first system process in the list to
|
|
|
|
* allow reliable asynchronous publishing of system events. RS comes right after
|
|
|
|
* to prioritize ping messages periodically delivered to system processes.
|
2006-03-10 17:10:05 +01:00
|
|
|
*
|
|
|
|
* Each entry provides the process number, flags, quantum size, scheduling
|
2009-12-11 01:08:19 +01:00
|
|
|
* queue, and a name for the process table. The initial program counter and
|
|
|
|
* stack size is also provided for kernel tasks.
|
2006-03-10 17:10:05 +01:00
|
|
|
*
|
|
|
|
* Note: the quantum size must be positive in all cases!
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
2006-06-20 11:56:06 +02:00
|
|
|
|
2005-07-29 17:26:23 +02:00
|
|
|
PUBLIC struct boot_image image[] = {
|
2010-05-25 10:06:14 +02:00
|
|
|
/* process nr, flags, ms, queue, stack, name */
|
2010-05-18 15:51:46 +02:00
|
|
|
{IDLE, 0, 0, 0, IDL_S, "idle" },
|
|
|
|
{CLOCK, 0, 0, 0, IDL_S, "clock" },
|
|
|
|
{SYSTEM, 0, 0, 0, IDL_S, "system"},
|
2010-05-26 20:45:55 +02:00
|
|
|
{HARDWARE, 0, 0, 0, HRD_S, "kernel"},
|
2010-03-23 00:44:55 +01:00
|
|
|
|
2010-05-25 10:06:14 +02:00
|
|
|
{DS_PROC_NR, BVM_F, 50, 4, 0, "ds" },
|
|
|
|
{RS_PROC_NR, 0, 50, 4, 0, "rs" },
|
2010-03-23 00:44:55 +01:00
|
|
|
|
2010-05-25 10:06:14 +02:00
|
|
|
{PM_PROC_NR, 0,500, 4, 0, "pm" },
|
|
|
|
{SCHED_PROC_NR, 0,500, 4, 0, "sched" },
|
2010-06-08 15:58:01 +02:00
|
|
|
{VFS_PROC_NR, 0,500, 5, 0, "vfs" },
|
2010-05-25 10:06:14 +02:00
|
|
|
{MEM_PROC_NR, BVM_F, 50, 3, 0, "memory"},
|
|
|
|
{LOG_PROC_NR, BVM_F, 50, 2, 0, "log" },
|
|
|
|
{TTY_PROC_NR, BVM_F, 50, 1, 0, "tty" },
|
|
|
|
{MFS_PROC_NR, BVM_F,500, 5, 0, "mfs" },
|
|
|
|
{VM_PROC_NR, 0,500, 2, 0, "vm" },
|
|
|
|
{PFS_PROC_NR, BVM_F,500, 5, 0, "pfs" },
|
|
|
|
{INIT_PROC_NR, BVM_F,200, USER_Q, 0, "init" },
|
2005-04-21 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
2005-08-04 21:23:03 +02:00
|
|
|
/* Verify the size of the system image table at compile time. Also verify that
|
|
|
|
* the first chunk of the ipc mask has enough bits to accommodate the processes
|
|
|
|
* in the image.
|
|
|
|
* If a problem is detected, the size of the 'dummy' array will be negative,
|
|
|
|
* causing a compile time error. Note that no space is actually allocated
|
|
|
|
* because 'dummy' is declared extern.
|
|
|
|
*/
|
2005-08-29 18:47:18 +02:00
|
|
|
extern int dummy[(NR_BOOT_PROCS==sizeof(image)/
|
|
|
|
sizeof(struct boot_image))?1:-1];
|
2005-08-04 21:23:03 +02:00
|
|
|
extern int dummy[(BITCHUNK_BITS > NR_BOOT_PROCS - 1) ? 1 : -1];
|