2005-04-21 16:53:53 +02:00
|
|
|
/* This file contains the main program of MINIX as well as its shutdown code.
|
|
|
|
* The routine main() initializes the system and starts the ball rolling by
|
|
|
|
* setting up the process table, interrupt vectors, and scheduling each task
|
|
|
|
* to run to initialize itself.
|
2005-06-24 18:24:40 +02:00
|
|
|
* The routine shutdown() does the opposite and brings down MINIX.
|
2005-04-21 16:53:53 +02:00
|
|
|
*
|
|
|
|
* The entries into this file are:
|
|
|
|
* main: MINIX main program
|
|
|
|
* prepare_shutdown: prepare to take MINIX down
|
|
|
|
*/
|
|
|
|
#include "kernel.h"
|
|
|
|
#include <signal.h>
|
2005-07-20 17:25:38 +02:00
|
|
|
#include <string.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <a.out.h>
|
|
|
|
#include <minix/callnr.h>
|
|
|
|
#include <minix/com.h>
|
'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
|
|
|
#include <minix/endpoint.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "proc.h"
|
|
|
|
|
2005-05-02 16:30:04 +02:00
|
|
|
/* Prototype declarations for PRIVATE functions. */
|
|
|
|
FORWARD _PROTOTYPE( void announce, (void));
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
FORWARD _PROTOTYPE( void shutdown, (timer_t *));
|
2005-05-02 16:30:04 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
2005-09-11 18:44:06 +02:00
|
|
|
* main *
|
2005-04-21 16:53:53 +02:00
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC void main()
|
|
|
|
{
|
|
|
|
/* Start the ball rolling. */
|
2005-07-29 17:26:23 +02:00
|
|
|
struct boot_image *ip; /* boot image pointer */
|
2005-07-20 17:25:38 +02:00
|
|
|
register struct proc *rp; /* process pointer */
|
|
|
|
register struct priv *sp; /* privilege structure pointer */
|
|
|
|
register int i, s;
|
2005-04-21 16:53:53 +02:00
|
|
|
int hdrindex; /* index to array of a.out headers */
|
2005-06-20 13:26:48 +02:00
|
|
|
phys_clicks text_base;
|
2006-05-11 16:49:46 +02:00
|
|
|
vir_clicks text_clicks, data_clicks, st_clicks;
|
2005-04-21 16:53:53 +02:00
|
|
|
reg_t ktsb; /* kernel task stack base */
|
|
|
|
struct exec e_hdr; /* for a copy of an a.out header */
|
|
|
|
|
2005-06-24 18:24:40 +02:00
|
|
|
/* Clear the process table. Anounce each slot as empty and set up mappings
|
2005-07-14 17:12:12 +02:00
|
|
|
* for proc_addr() and proc_nr() macros. Do the same for the table with
|
2005-07-26 14:48:34 +02:00
|
|
|
* privilege structures for the system processes.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
for (rp = BEG_PROC_ADDR, i = -NR_TASKS; rp < END_PROC_ADDR; ++rp, ++i) {
|
2005-06-30 17:55:19 +02:00
|
|
|
rp->p_rts_flags = SLOT_FREE; /* initialize free slot */
|
2005-04-21 16:53:53 +02:00
|
|
|
rp->p_nr = i; /* proc number from ptr */
|
'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
|
|
|
rp->p_endpoint = _ENDPOINT(0, rp->p_nr); /* generation no. 0 */
|
2005-04-21 16:53:53 +02:00
|
|
|
(pproc_addr + NR_TASKS)[i] = rp; /* proc ptr from number */
|
|
|
|
}
|
2005-07-14 17:12:12 +02:00
|
|
|
for (sp = BEG_PRIV_ADDR, i = 0; sp < END_PRIV_ADDR; ++sp, ++i) {
|
|
|
|
sp->s_proc_nr = NONE; /* initialize as free */
|
|
|
|
sp->s_id = i; /* priv structure index */
|
|
|
|
ppriv_addr[i] = sp; /* priv ptr from number */
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-10-02 21:02:05 +02:00
|
|
|
/* Set up proc table entries for processes in boot image. The stacks of the
|
2005-04-21 16:53:53 +02:00
|
|
|
* kernel tasks are initialized to an array in data space. The stacks
|
|
|
|
* of the servers have been added to the data segment by the monitor, so
|
|
|
|
* the stack pointer is set to the end of the data segment. All the
|
|
|
|
* processes are in low memory on the 8086. On the 386 only the kernel
|
|
|
|
* is in low memory, the rest is loaded in extended memory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Task stacks. */
|
|
|
|
ktsb = (reg_t) t_stack;
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
for (i=0; i < NR_BOOT_PROCS; ++i) {
|
2006-06-20 11:56:06 +02:00
|
|
|
int ci;
|
|
|
|
bitchunk_t fv;
|
2005-07-14 17:12:12 +02:00
|
|
|
ip = &image[i]; /* process' attributes */
|
|
|
|
rp = proc_addr(ip->proc_nr); /* get process pointer */
|
'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
|
|
|
ip->endpoint = rp->p_endpoint; /* ipc endpoint */
|
2005-06-30 17:55:19 +02:00
|
|
|
rp->p_max_priority = ip->priority; /* max scheduling priority */
|
|
|
|
rp->p_priority = ip->priority; /* current priority */
|
|
|
|
rp->p_quantum_size = ip->quantum; /* quantum size in ticks */
|
2005-08-22 17:14:11 +02:00
|
|
|
rp->p_ticks_left = ip->quantum; /* current credit */
|
2005-07-21 20:36:40 +02:00
|
|
|
strncpy(rp->p_name, ip->proc_name, P_NAME_LEN); /* set process name */
|
2005-07-26 14:48:34 +02:00
|
|
|
(void) get_priv(rp, (ip->flags & SYS_PROC)); /* assign structure */
|
|
|
|
priv(rp)->s_flags = ip->flags; /* process flags */
|
2005-08-04 21:23:03 +02:00
|
|
|
priv(rp)->s_trap_mask = ip->trap_mask; /* allowed traps */
|
2006-06-20 11:56:06 +02:00
|
|
|
|
|
|
|
/* Initialize call mask bitmap from unordered set.
|
|
|
|
* A single SYS_ALL_CALLS is a special case - it
|
|
|
|
* means all calls are allowed.
|
|
|
|
*/
|
|
|
|
if(ip->nr_k_calls == 1 && ip->k_calls[0] == SYS_ALL_CALLS)
|
|
|
|
fv = ~0; /* fill call mask */
|
|
|
|
else
|
|
|
|
fv = 0; /* clear call mask */
|
|
|
|
|
|
|
|
for(ci = 0; ci < CALL_MASK_SIZE; ci++) /* fill or clear call mask */
|
|
|
|
priv(rp)->s_k_call_mask[ci] = fv;
|
|
|
|
if(!fv) /* not all full? enter calls bit by bit */
|
|
|
|
for(ci = 0; ci < ip->nr_k_calls; ci++)
|
|
|
|
SET_BIT(priv(rp)->s_k_call_mask,
|
|
|
|
ip->k_calls[ci]-KERNEL_CALL);
|
|
|
|
|
2005-08-04 21:23:03 +02:00
|
|
|
priv(rp)->s_ipc_to.chunk[0] = ip->ipc_to; /* restrict targets */
|
2005-07-26 14:48:34 +02:00
|
|
|
if (iskerneln(proc_nr(rp))) { /* part of the kernel? */
|
2005-06-30 17:55:19 +02:00
|
|
|
if (ip->stksize > 0) { /* HARDWARE stack size is 0 */
|
2005-07-14 17:12:12 +02:00
|
|
|
rp->p_priv->s_stack_guard = (reg_t *) ktsb;
|
|
|
|
*rp->p_priv->s_stack_guard = STACK_GUARD;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-06-30 17:55:19 +02:00
|
|
|
ktsb += ip->stksize; /* point to high end of stack */
|
2005-04-21 16:53:53 +02:00
|
|
|
rp->p_reg.sp = ktsb; /* this task's initial stack ptr */
|
|
|
|
hdrindex = 0; /* all use the first a.out header */
|
|
|
|
} else {
|
2005-07-26 14:48:34 +02:00
|
|
|
hdrindex = 1 + i-NR_TASKS; /* servers, drivers, INIT */
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The bootstrap loader created an array of the a.out headers at
|
|
|
|
* absolute address 'aout'. Get one element to e_hdr.
|
|
|
|
*/
|
|
|
|
phys_copy(aout + hdrindex * A_MINHDR, vir2phys(&e_hdr),
|
2005-07-26 14:48:34 +02:00
|
|
|
(phys_bytes) A_MINHDR);
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Convert addresses to clicks and build process memory map */
|
|
|
|
text_base = e_hdr.a_syms >> CLICK_SHIFT;
|
|
|
|
text_clicks = (e_hdr.a_text + CLICK_SIZE-1) >> CLICK_SHIFT;
|
2006-05-11 16:49:46 +02:00
|
|
|
data_clicks = (e_hdr.a_data+e_hdr.a_bss + CLICK_SIZE-1) >> CLICK_SHIFT;
|
|
|
|
st_clicks= (e_hdr.a_total + CLICK_SIZE-1) >> CLICK_SHIFT;
|
|
|
|
if (!(e_hdr.a_flags & A_SEP))
|
|
|
|
{
|
|
|
|
data_clicks= (e_hdr.a_text+e_hdr.a_data+e_hdr.a_bss +
|
|
|
|
CLICK_SIZE-1) >> CLICK_SHIFT;
|
|
|
|
text_clicks = 0; /* common I&D */
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
rp->p_memmap[T].mem_phys = text_base;
|
|
|
|
rp->p_memmap[T].mem_len = text_clicks;
|
|
|
|
rp->p_memmap[D].mem_phys = text_base + text_clicks;
|
|
|
|
rp->p_memmap[D].mem_len = data_clicks;
|
2006-05-11 16:49:46 +02:00
|
|
|
rp->p_memmap[S].mem_phys = text_base + text_clicks + st_clicks;
|
|
|
|
rp->p_memmap[S].mem_vir = st_clicks;
|
|
|
|
rp->p_memmap[S].mem_len = 0;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Set initial register values. The processor status word for tasks
|
|
|
|
* is different from that of other processes because tasks can
|
|
|
|
* access I/O; this is not allowed to less-privileged processes
|
|
|
|
*/
|
2005-06-30 17:55:19 +02:00
|
|
|
rp->p_reg.pc = (reg_t) ip->initial_pc;
|
2005-06-24 18:24:40 +02:00
|
|
|
rp->p_reg.psw = (iskernelp(rp)) ? INIT_TASK_PSW : INIT_PSW;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Initialize the server stack pointer. Take it down one word
|
|
|
|
* to give crtso.s something to use as "argc".
|
|
|
|
*/
|
2005-07-26 14:48:34 +02:00
|
|
|
if (isusern(proc_nr(rp))) { /* user-space process? */
|
2005-04-21 16:53:53 +02:00
|
|
|
rp->p_reg.sp = (rp->p_memmap[S].mem_vir +
|
|
|
|
rp->p_memmap[S].mem_len) << CLICK_SHIFT;
|
|
|
|
rp->p_reg.sp -= sizeof(reg_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set ready. The HARDWARE task is never ready. */
|
Mostly bugfixes of bugs triggered by the test set.
bugfixes:
SYSTEM:
. removed
rc->p_priv->s_flags = 0;
for the priv struct shared by all user processes in get_priv(). this
should only be done once. doing a SYS_PRIV_USER in sys_privctl()
caused the flags of all user processes to be reset, so they were no
longer PREEMPTIBLE. this happened when RS executed a policy script.
(this broke test1 in the test set)
VFS/MFS:
. chown can change the mode of a file, and chmod arguments are only
part of the full file mode so the full filemode is slightly magic.
changed these calls so that the final modes are returned to VFS, so
that the vnode can be kept up-to-date.
(this broke test11 in the test set)
MFS:
. lookup() checked for sizeof(string) instead of sizeof(user_path),
truncating long path names
(caught by test 23)
. truncate functions neglected to update ctime
(this broke test16)
VFS:
. corner case of an empty filename lookup caused fields of a request
not to be filled in in the lookup functions, not making it clear
that the lookup had failed, causing messages to garbage processes,
causing strange failures.
(caught by test 30)
. trust v_size in vnode when doing reads or writes on non-special
files, truncating i/o where necessary; this is necessary for pipes,
as MFS can't tell when a pipe has been truncated without it being
told explicitly each time.
when the last reader/writer on a pipe closes, tell FS about
the new size using truncate_vn().
(this broke test 25, among others)
. permission check for chdir() had disappeared; added a
forbidden() call
(caught by test 23)
new code, shouldn't change anything:
. introduced RTS_SET, RTS_UNSET, and RTS_ISSET macro's, and their
LOCK variants. These macros set and clear the p_rts_flags field,
causing a lot of duplicated logic like
old_flags = rp->p_rts_flags; /* save value of the flags */
rp->p_rts_flags &= ~NO_PRIV;
if (old_flags != 0 && rp->p_rts_flags == 0) lock_enqueue(rp);
to change into the simpler
RTS_LOCK_UNSET(rp, NO_PRIV);
so the macros take care of calling dequeue() and enqueue() (or lock_*()),
as the case may be). This makes the code a bit more readable and a
bit less fragile.
. removed return code from do_clocktick in CLOCK as it currently
never replies
. removed some debug code from VFS
. fixed grant debug message in device.c
preemptive checks, tests, changes:
. added return code checks of receive() to SYSTEM and CLOCK
. O_TRUNC should never arrive at MFS (added sanity check and removed
O_TRUNC code)
. user_path declared with PATH_MAX+1 to let it be null-terminated
. checks in MFS to see if strings passed by VFS are null-terminated
IS:
. static irq name table thrown out
2007-02-01 18:50:02 +01:00
|
|
|
if (rp->p_nr == HARDWARE) RTS_LOCK_SET(rp, NO_PRIORITY);
|
|
|
|
RTS_LOCK_UNSET(rp, SLOT_FREE); /* remove SLOT_FREE and schedule */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Code and data segments must be allocated in protected mode. */
|
|
|
|
alloc_segments(rp);
|
|
|
|
}
|
|
|
|
|
2006-10-30 16:53:38 +01:00
|
|
|
#if SPROFILE
|
|
|
|
sprofiling = 0; /* we're not profiling until instructed to */
|
|
|
|
#endif /* SPROFILE */
|
|
|
|
#if CPROFILE
|
|
|
|
cprof_procs_no = 0; /* init nr of hash table slots used */
|
|
|
|
#endif /* CPROFILE */
|
|
|
|
|
2005-06-17 11:09:54 +02:00
|
|
|
/* MINIX is now ready. All boot image processes are on the ready queue.
|
|
|
|
* Return to the assembly code to start running the current process.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
2005-06-17 11:09:54 +02:00
|
|
|
bill_ptr = proc_addr(IDLE); /* it has to point somewhere */
|
|
|
|
announce(); /* print MINIX startup banner */
|
2005-04-21 16:53:53 +02:00
|
|
|
restart();
|
|
|
|
}
|
|
|
|
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* announce *
|
|
|
|
*===========================================================================*/
|
2005-04-21 16:53:53 +02:00
|
|
|
PRIVATE void announce(void)
|
|
|
|
{
|
|
|
|
/* Display the MINIX startup banner. */
|
2005-10-06 12:21:24 +02:00
|
|
|
kprintf("\nMINIX %s.%s. "
|
2005-10-06 11:39:36 +02:00
|
|
|
"Copyright 2006, Vrije Universiteit, Amsterdam, The Netherlands\n",
|
2005-07-20 17:25:38 +02:00
|
|
|
OS_RELEASE, OS_VERSION);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* prepare_shutdown *
|
|
|
|
*===========================================================================*/
|
2005-07-27 16:32:16 +02:00
|
|
|
PUBLIC void prepare_shutdown(how)
|
|
|
|
int how;
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2005-07-27 16:32:16 +02:00
|
|
|
/* This function prepares to shutdown MINIX. */
|
2005-07-21 20:36:40 +02:00
|
|
|
static timer_t shutdown_timer;
|
2005-07-29 17:26:23 +02:00
|
|
|
register struct proc *rp;
|
2005-05-24 12:06:17 +02:00
|
|
|
message m;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-07-20 17:25:38 +02:00
|
|
|
/* Send a signal to all system processes that are still alive to inform
|
|
|
|
* them that the MINIX kernel is shutting down. A proper shutdown sequence
|
|
|
|
* should be implemented by a user-space server. This mechanism is useful
|
|
|
|
* as a backup in case of system panics, so that system processes can still
|
|
|
|
* run their shutdown code, e.g, to synchronize the FS or to let the TTY
|
|
|
|
* switch to the first console.
|
|
|
|
*/
|
2006-03-10 17:10:05 +01:00
|
|
|
#if DEAD_CODE
|
2005-07-21 20:36:40 +02:00
|
|
|
kprintf("Sending SIGKSTOP to system processes ...\n");
|
2005-07-20 17:25:38 +02:00
|
|
|
for (rp=BEG_PROC_ADDR; rp<END_PROC_ADDR; rp++) {
|
2005-07-21 20:36:40 +02:00
|
|
|
if (!isemptyp(rp) && (priv(rp)->s_flags & SYS_PROC) && !iskernelp(rp))
|
2005-07-20 17:25:38 +02:00
|
|
|
send_sig(proc_nr(rp), SIGKSTOP);
|
|
|
|
}
|
2006-03-10 17:10:05 +01:00
|
|
|
#endif
|
2005-07-19 14:21:36 +02:00
|
|
|
|
2005-10-05 11:51:50 +02:00
|
|
|
/* Continue after 1 second, to give processes a chance to get scheduled to
|
|
|
|
* do shutdown work. Set a watchog timer to call shutdown(). The timer
|
2005-07-20 17:25:38 +02:00
|
|
|
* argument passes the shutdown status.
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
2005-07-21 20:36:40 +02:00
|
|
|
kprintf("MINIX will now be shut down ...\n");
|
|
|
|
tmr_arg(&shutdown_timer)->ta_int = how;
|
2005-07-29 17:26:23 +02:00
|
|
|
set_timer(&shutdown_timer, get_uptime() + HZ, shutdown);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
2005-09-11 18:44:06 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* shutdown *
|
|
|
|
*===========================================================================*/
|
2005-05-27 14:44:14 +02:00
|
|
|
PRIVATE void shutdown(tp)
|
|
|
|
timer_t *tp;
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
/* This function is called from prepare_shutdown or stop_sequence to bring
|
2005-06-24 18:24:40 +02:00
|
|
|
* down MINIX. How to shutdown is in the argument: RBT_HALT (return to the
|
|
|
|
* monitor), RBT_MONITOR (execute given code), RBT_RESET (hard reset).
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
intr_init(INTS_ORIG);
|
2005-04-21 16:53:53 +02:00
|
|
|
clock_stop();
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
arch_shutdown(tmr_arg(tp)->ta_int);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|