diff --git a/kernel/arch/i386/arch_do_vmctl.c b/kernel/arch/i386/arch_do_vmctl.c index 56b081b14..79f1dc9dd 100644 --- a/kernel/arch/i386/arch_do_vmctl.c +++ b/kernel/arch/i386/arch_do_vmctl.c @@ -12,7 +12,7 @@ #include "proto.h" -extern u32_t *vm_pagedirs; +extern u8_t *vm_pagedirs; /*===========================================================================* * arch_do_vmctl * @@ -64,7 +64,7 @@ struct proc *p; } case VMCTL_I386_PAGEDIRS: { - vm_pagedirs = (u32_t *) m_ptr->SVMCTL_VALUE; + vm_pagedirs = (u8_t *) m_ptr->SVMCTL_VALUE; return OK; } case VMCTL_I386_FREEPDE: diff --git a/kernel/arch/i386/hw_intr.h b/kernel/arch/i386/hw_intr.h index 278a82716..1665b7818 100644 --- a/kernel/arch/i386/hw_intr.h +++ b/kernel/arch/i386/hw_intr.h @@ -5,8 +5,8 @@ /* legacy PIC */ -_PROTOTYPE(int irq_8259_unmask,(int irq)); -_PROTOTYPE(int irq_8259_mask,(int irq)); +_PROTOTYPE(void irq_8259_unmask,(int irq)); +_PROTOTYPE(void irq_8259_mask,(int irq)); _PROTOTYPE(void irq_handle,(int irq)); #define hw_intr_mask(irq) irq_8259_mask(irq) diff --git a/kernel/arch/i386/i8259.c b/kernel/arch/i386/i8259.c index 70c781830..afab1e213 100644 --- a/kernel/arch/i386/i8259.c +++ b/kernel/arch/i386/i8259.c @@ -23,8 +23,6 @@ #define ICW4_PC_AEOI_SLAVE 0x0B /* not SFNM, buffered, auto EOI, 8086 */ #define ICW4_PC_AEOI_MASTER 0x0F /* not SFNM, buffered, auto EOI, 8086 */ -#define set_vec(nr, addr) ((void)0) - /*===========================================================================* * intr_init * *===========================================================================*/ diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 8f640bffa..331ae3b04 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -31,7 +31,7 @@ PRIVATE int psok = 0; I386_PAGE_SIZE * pr->p_nr + \ I386_VM_PT_ENT_SIZE * pi)) -u8_t *vm_pagedirs = NULL; +PUBLIC u8_t *vm_pagedirs = NULL; #define NOPDE (-1) #define PDEMASK(n) (1L << (n)) @@ -41,7 +41,7 @@ PRIVATE int nfreepdes = 0, freepdes[WANT_FREEPDES], inusepde = NOPDE; #define HASPT(procptr) ((procptr)->p_seg.p_cr3 != 0) -FORWARD _PROTOTYPE( u32_t phys_get32, (vir_bytes v) ); +FORWARD _PROTOTYPE( u32_t phys_get32, (phys_bytes v) ); FORWARD _PROTOTYPE( void vm_enable_paging, (void) ); FORWARD _PROTOTYPE( void set_cr3, (void) ); @@ -423,9 +423,10 @@ vir_bytes bytes; /* # of bytes to be copied */ u32_t phys = 0; if(seg == MEM_GRANT) { - phys = umap_grant(rp, vir_addr, bytes); - } else { - if(!(linear = umap_local(rp, seg, vir_addr, bytes))) { + return umap_grant(rp, vir_addr, bytes); + } + + if(!(linear = umap_local(rp, seg, vir_addr, bytes))) { kprintf("SYSTEM:umap_virtual: umap_local failed\n"); phys = 0; } else { @@ -436,7 +437,7 @@ vir_bytes bytes; /* # of bytes to be copied */ if(phys == 0) minix_panic("vm_lookup returned phys", phys); } - } + if(phys == 0) { kprintf("SYSTEM:umap_virtual: lookup failed\n"); @@ -517,22 +518,6 @@ PUBLIC int vm_lookup(struct proc *proc, vir_bytes virtual, vir_bytes *physical, NOREC_RETURN(vmlookup, OK); } -/* From virtual address v in process p, - * lookup physical address and assign it to d. - * If p is NULL, assume it's already a physical address. - */ -#define LOOKUP(d, p, v, flagsp) { \ - int r; \ - if(!(p)) { (d) = (v); } \ - else { \ - if((r=vm_lookup((p), (v), &(d), flagsp)) != OK) { \ - kprintf("vm_copy: lookup failed of 0x%lx in %d (%s)\n"\ - "kernel stacktrace: ", (v), (p)->p_endpoint, \ - (p)->p_name); \ - util_stacktrace(); \ - return r; \ - } } } - /*===========================================================================* * vm_contiguous * *===========================================================================*/ @@ -770,7 +755,7 @@ int vm_phys_memset(phys_bytes ph, u8_t c, phys_bytes bytes) */ while(bytes > 0) { int pde, t; - vir_bytes chunk = bytes; + vir_bytes chunk = (vir_bytes) bytes; phys_bytes ptr; inusepde = NOPDE; CREATEPDE(((struct proc *) NULL), ptr, ph, chunk, bytes, pde, t); @@ -1047,7 +1032,7 @@ PUBLIC arch_phys_map(int index, phys_bytes *addr, phys_bytes *len, int *flags) #endif } -PUBLIC arch_phys_map_reply(int index, vir_bytes addr) +PUBLIC int arch_phys_map_reply(int index, vir_bytes addr) { #ifdef CONFIG_APIC /* if local APIC is enabled */ diff --git a/kernel/main.c b/kernel/main.c index 9437ebaf0..d154e94af 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -54,7 +54,7 @@ PUBLIC void main() } 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 */ + sp->s_id = (proc_nr_t) i; /* priv structure index */ ppriv_addr[i] = sp; /* priv ptr from number */ } @@ -70,7 +70,8 @@ PUBLIC void main() ktsb = (reg_t) t_stack; for (i=0; i < NR_BOOT_PROCS; ++i) { - int schedulable_proc, proc_nr; + int schedulable_proc; + proc_nr_t proc_nr; int ipc_to_m, kcalls; ip = &image[i]; /* process' attributes */ @@ -112,6 +113,10 @@ PUBLIC void main() ipc_to_m = RSYS_M; /* allowed targets */ kcalls = RSYS_KC; /* allowed kernel calls */ } + /* Priviliges for ordinary process. */ + else { + NOT_REACHABLE; + } /* Fill in target mask. */ for (j=0; j < NR_SYS_PROCS; j++) { diff --git a/kernel/proc.c b/kernel/proc.c index 5096608f8..4ee6592ab 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -506,7 +506,7 @@ long bit_map; /* notification event set or flags */ PRIVATE int deadlock(function, cp, src_dst) int function; /* trap number */ register struct proc *cp; /* pointer to caller */ -int src_dst; /* src or dst process */ +proc_nr_t src_dst; /* src or dst process */ { /* Check for deadlock. This can happen if 'caller_ptr' and 'src_dst' have * a cyclic dependency of blocking send and receive calls. The only cyclic diff --git a/kernel/proto.h b/kernel/proto.h index dbd979852..c06c4a1cb 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -56,7 +56,7 @@ _PROTOTYPE( int get_priv, (register struct proc *rc, int proc_type) ); _PROTOTYPE( void set_sendto_bit, (struct proc *rc, int id) ); _PROTOTYPE( void unset_sendto_bit, (struct proc *rc, int id) ); _PROTOTYPE( void send_sig, (int proc_nr, int sig_nr) ); -_PROTOTYPE( void cause_sig, (int proc_nr, int sig_nr) ); +_PROTOTYPE( void cause_sig, (proc_nr_t proc_nr, int sig_nr) ); _PROTOTYPE( void sig_delay_done, (struct proc *rp) ); _PROTOTYPE( void sys_task, (void) ); #define numap_local(proc_nr, vir_addr, bytes) \ diff --git a/kernel/system.c b/kernel/system.c index 3d2692479..93ba522c0 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -337,7 +337,7 @@ PUBLIC void send_sig(int proc_nr, int sig_nr) * cause_sig * *===========================================================================*/ PUBLIC void cause_sig(proc_nr, sig_nr) -int proc_nr; /* process to be signalled */ +proc_nr_t proc_nr; /* process to be signalled */ int sig_nr; /* signal to be sent */ { /* A system process wants to send a signal to a process. Examples are: diff --git a/kernel/system/do_copy.c b/kernel/system/do_copy.c index e46d33f28..cf42a75ee 100644 --- a/kernel/system/do_copy.c +++ b/kernel/system/do_copy.c @@ -83,7 +83,7 @@ register message *m_ptr; /* pointer to request message */ /* Check for overflow. This would happen for 64K segments and 16-bit * vir_bytes. Especially copying by the PM on do_fork() is affected. */ - if (bytes != (vir_bytes) bytes) return(E2BIG); + if (bytes != (phys_bytes) (vir_bytes) bytes) return(E2BIG); /* Now try to make the actual virtual copy. */ return( virtual_copy_vmcheck(&vir_addr[_SRC_], &vir_addr[_DST_], bytes) ); diff --git a/kernel/system/do_kill.c b/kernel/system/do_kill.c index dacf43d42..ac27db68c 100644 --- a/kernel/system/do_kill.c +++ b/kernel/system/do_kill.c @@ -28,7 +28,7 @@ message *m_ptr; /* pointer to request message */ proc_nr_t proc_nr, proc_nr_e; int sig_nr = m_ptr->SIG_NUMBER; - proc_nr_e= m_ptr->SIG_ENDPT; + proc_nr_e= (proc_nr_t) m_ptr->SIG_ENDPT; if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL); if (sig_nr >= _NSIG) return(EINVAL); diff --git a/kernel/system/do_safecopy.c b/kernel/system/do_safecopy.c index c13d963ef..402941e0e 100644 --- a/kernel/system/do_safecopy.c +++ b/kernel/system/do_safecopy.c @@ -45,7 +45,7 @@ endpoint_t *e_granter; /* new granter (magic grants) */ { static cp_grant_t g; static int proc_nr; - static struct proc *granter_proc; + static const struct proc *granter_proc; int r, depth = 0; do { diff --git a/kernel/system/do_safemap.c b/kernel/system/do_safemap.c index b76c52876..403f8638f 100644 --- a/kernel/system/do_safemap.c +++ b/kernel/system/do_safemap.c @@ -121,7 +121,7 @@ PUBLIC int map_invoke_vm(int req_type, /* VMPTYPE_... COWMAP, SMAP, SUNMAP */ size_t size, int flag) { struct proc *caller, *src, *dst; - vir_bytes lin_src, lin_dst; + phys_bytes lin_src, lin_dst; src = endpoint_lookup(end_s); dst = endpoint_lookup(end_d); @@ -154,7 +154,7 @@ PUBLIC int map_invoke_vm(int req_type, /* VMPTYPE_... COWMAP, SMAP, SUNMAP */ caller->p_vmrequest.params.map.vir_d = lin_dst; /* destination addr */ caller->p_vmrequest.params.map.ep_s = end_s; /* source process */ caller->p_vmrequest.params.map.vir_s = lin_src; /* source address */ - caller->p_vmrequest.params.map.length = size; + caller->p_vmrequest.params.map.length = (vir_bytes) size; caller->p_vmrequest.params.map.writeflag = flag; caller->p_vmrequest.type = VMSTYPE_MAP; @@ -175,10 +175,10 @@ register message *m_ptr; { endpoint_t grantor = m_ptr->SMAP_EP; cp_grant_id_t gid = m_ptr->SMAP_GID; - vir_bytes offset = m_ptr->SMAP_OFFSET; - int seg = (int)m_ptr->SMAP_SEG; - vir_bytes address = m_ptr->SMAP_ADDRESS; - vir_bytes bytes = m_ptr->SMAP_BYTES; + vir_bytes offset = (vir_bytes) m_ptr->SMAP_OFFSET; + int seg = (int) m_ptr->SMAP_SEG; + vir_bytes address = (vir_bytes) m_ptr->SMAP_ADDRESS; + vir_bytes bytes = (vir_bytes) m_ptr->SMAP_BYTES; int flag = m_ptr->SMAP_FLAG; vir_bytes offset_result; diff --git a/kernel/utility.c b/kernel/utility.c index 228f3afc4..07989df5e 100644 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -15,10 +15,7 @@ /*===========================================================================* * panic * *===========================================================================*/ -PUBLIC void panic(what, mess,nr) -char *what; -char *mess; -int nr; +PUBLIC void panic(char *what, char *mess,int nr) { /* This function is for when a library call wants to panic. * The library call calls printf() and tries to exit a process, @@ -30,9 +27,7 @@ int nr; /*===========================================================================* * minix_panic * *===========================================================================*/ -PUBLIC void minix_panic(mess,nr) -char *mess; -int nr; +PUBLIC void minix_panic(char *mess,int nr) { /* The system has run aground of a fatal kernel error. Terminate execution. */ if (minix_panicing++) {