From f47668c74af022acf4041b7c4b5b2fa37a2834b5 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 20 Aug 2013 14:14:28 +0000 Subject: [PATCH] kernel: make WARNS=5 proof Change-Id: I68c2ac3f420f245e5410732ce5019d37e7cbf206 --- include/minix/type.h | 2 +- kernel/Makefile | 2 + kernel/arch/earm/arch_do_vmctl.c | 4 +- kernel/arch/earm/arch_reset.c | 2 +- kernel/arch/earm/arch_system.c | 10 +-- kernel/arch/earm/exception.c | 2 +- kernel/arch/earm/include/arch_proto.h | 2 + kernel/arch/earm/include/cpufunc.h | 26 ++++---- kernel/arch/earm/memory.c | 90 +++++++++++++-------------- kernel/arch/earm/omap_serial.c | 3 +- kernel/arch/earm/omap_serial.h | 2 +- kernel/arch/earm/omap_timer.c | 6 +- kernel/arch/earm/pg_utils.c | 10 +-- kernel/arch/earm/protect.c | 8 +-- kernel/arch/i386/acpi.c | 17 +++-- kernel/arch/i386/apic.c | 18 +++--- kernel/arch/i386/arch_clock.c | 8 +-- kernel/arch/i386/arch_do_vmctl.c | 5 +- kernel/arch/i386/arch_system.c | 17 ++--- kernel/arch/i386/arch_watchdog.c | 16 ++--- kernel/arch/i386/direct_tty_utils.c | 2 +- kernel/arch/i386/do_readbios.c | 3 +- kernel/arch/i386/do_sdevio.c | 5 +- kernel/arch/i386/exception.c | 4 +- kernel/arch/i386/include/arch_proto.h | 8 +++ kernel/arch/i386/memory.c | 76 +++++++++++----------- kernel/arch/i386/pg_utils.c | 12 ++-- kernel/arch/i386/pre_init.c | 9 ++- kernel/arch/i386/protect.c | 40 ++++++------ kernel/clock.c | 12 ++-- kernel/debug.c | 8 +-- kernel/glo.h | 2 +- kernel/main.c | 18 +++--- kernel/proc.c | 24 +++---- kernel/proto.h | 16 ++--- kernel/system.c | 23 +++---- kernel/system/do_devio.c | 4 +- kernel/system/do_getinfo.c | 2 +- kernel/system/do_irqctl.c | 5 +- kernel/system/do_privctl.c | 64 +++++++++---------- kernel/system/do_safecopy.c | 26 +++----- kernel/system/do_sigsend.c | 4 +- kernel/system/do_sysctl.c | 3 +- kernel/system/do_umap_remote.c | 2 +- kernel/system/do_vdevio.c | 4 +- kernel/system/do_vtimer.c | 3 +- kernel/table.c | 34 +++++----- kernel/utility.c | 8 +-- lib/libsys/assert.c | 8 +-- lib/libsys/stacktrace.c | 1 + lib/libsys/vprintf.c | 29 +++++---- 51 files changed, 352 insertions(+), 357 deletions(-) diff --git a/include/minix/type.h b/include/minix/type.h index b6ed40d44..f589f19eb 100644 --- a/include/minix/type.h +++ b/include/minix/type.h @@ -135,7 +135,7 @@ struct memory { /* The kernel outputs diagnostic messages in a circular buffer. */ struct kmessages { int km_next; /* next index to write */ - int km_size; /* current size in buffer */ + unsigned int km_size; /* current size in buffer */ char km_buf[_KMESS_BUF_SIZE]; /* buffer for messages */ char kmess_buf[80*25]; /* printable copy of message buffer */ int blpos; /* kmess_buf position */ diff --git a/kernel/Makefile b/kernel/Makefile index c16eadcc9..82634b667 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -3,6 +3,8 @@ USE_BITCODE:=no +WARNS=5 + BINDIR= /usr/sbin MAN= PROG= kernel diff --git a/kernel/arch/earm/arch_do_vmctl.c b/kernel/arch/earm/arch_do_vmctl.c index 26f563d95..3692f040b 100644 --- a/kernel/arch/earm/arch_do_vmctl.c +++ b/kernel/arch/earm/arch_do_vmctl.c @@ -32,9 +32,7 @@ static void set_ttbr(struct proc *p, u32_t ttbr, u32_t *v) /*===========================================================================* * arch_do_vmctl * *===========================================================================*/ -int arch_do_vmctl(m_ptr, p) -register message *m_ptr; /* pointer to request message */ -struct proc *p; +int arch_do_vmctl(register message *m_ptr, struct proc *p) { switch(m_ptr->SVMCTL_PARAM) { case VMCTL_GET_PDBR: diff --git a/kernel/arch/earm/arch_reset.c b/kernel/arch/earm/arch_reset.c index b6d16870e..8f0d31904 100644 --- a/kernel/arch/earm/arch_reset.c +++ b/kernel/arch/earm/arch_reset.c @@ -40,7 +40,7 @@ reset(void) while (1); } -void +static void poweroff(void) { diff --git a/kernel/arch/earm/arch_system.c b/kernel/arch/earm/arch_system.c index 1bb48a9d6..2d4af7b33 100644 --- a/kernel/arch/earm/arch_system.c +++ b/kernel/arch/earm/arch_system.c @@ -141,17 +141,17 @@ void arch_init(void) /*===========================================================================* * do_ser_debug * *===========================================================================*/ -void do_ser_debug() +void do_ser_debug(void) { } -void arch_do_syscall(struct proc *proc) +void arch_do_syscall(struct proc *whichproc) { /* do_ipc assumes that it's running because of the current process */ - assert(proc == get_cpulocal_var(proc_ptr)); + assert(whichproc == get_cpulocal_var(proc_ptr)); /* Make the system call, for real this time. */ - proc->p_reg.retreg = - do_ipc(proc->p_reg.retreg, proc->p_reg.r1, proc->p_reg.r2); + whichproc->p_reg.retreg = + do_ipc(whichproc->p_reg.retreg, whichproc->p_reg.r1, whichproc->p_reg.r2); } reg_t svc_stack; diff --git a/kernel/arch/earm/exception.c b/kernel/arch/earm/exception.c index 84b4fe62a..bcecc8358 100644 --- a/kernel/arch/earm/exception.c +++ b/kernel/arch/earm/exception.c @@ -13,7 +13,7 @@ #include struct ex_s { - char *msg; + const char *msg; int signum; }; diff --git a/kernel/arch/earm/include/arch_proto.h b/kernel/arch/earm/include/arch_proto.h index cdf717ba9..cebf463d3 100644 --- a/kernel/arch/earm/include/arch_proto.h +++ b/kernel/arch/earm/include/arch_proto.h @@ -45,6 +45,8 @@ phys_bytes pg_load(void); void pg_map(phys_bytes phys, vir_bytes vaddr, vir_bytes vaddr_end, kinfo_t *cbi); int pg_mapkernel(void); void pg_mapproc(struct proc *p, struct boot_image *ip, kinfo_t *cbi); +void omap3_irq_handle(void); +void exception_handler(int is_nested, reg_t *saved_lr, int vector); EXTERN void * k_stacks_start; extern void * k_stacks; diff --git a/kernel/arch/earm/include/cpufunc.h b/kernel/arch/earm/include/cpufunc.h index fbdc054a2..5c9c74cda 100644 --- a/kernel/arch/earm/include/cpufunc.h +++ b/kernel/arch/earm/include/cpufunc.h @@ -74,7 +74,7 @@ static inline void refresh_tlb(void) /* Read System Control Register */ -static inline u32_t read_sctlr() +static inline u32_t read_sctlr(void) { u32_t ctl; @@ -93,7 +93,7 @@ static inline void write_sctlr(u32_t ctl) } /* Read Translation Table Base Register 0 */ -static inline u32_t read_ttbr0() +static inline u32_t read_ttbr0(void) { u32_t bar; @@ -123,7 +123,7 @@ static inline void reload_ttbr0(void) } /* Read Translation Table Base Register 1 */ -static inline u32_t read_ttbr1() +static inline u32_t read_ttbr1(void) { u32_t bar; @@ -153,7 +153,7 @@ static inline void reload_ttbr1(void) } /* Read Translation Table Base Control Register */ -static inline u32_t read_ttbcr() +static inline u32_t read_ttbcr(void) { u32_t bcr; @@ -173,7 +173,7 @@ static inline void write_ttbcr(u32_t bcr) } /* Read Domain Access Control Register */ -static inline u32_t read_dacr() +static inline u32_t read_dacr(void) { u32_t dacr; @@ -193,7 +193,7 @@ static inline void write_dacr(u32_t dacr) } /* Read Data Fault Status Register */ -static inline u32_t read_dfsr() +static inline u32_t read_dfsr(void) { u32_t fsr; @@ -213,7 +213,7 @@ static inline void write_dfsr(u32_t fsr) } /* Read Instruction Fault Status Register */ -static inline u32_t read_ifsr() +static inline u32_t read_ifsr(void) { u32_t fsr; @@ -233,7 +233,7 @@ static inline void write_ifsr(u32_t fsr) } /* Read Data Fault Address Register */ -static inline u32_t read_dfar() +static inline u32_t read_dfar(void) { u32_t far; @@ -253,7 +253,7 @@ static inline void write_dfar(u32_t far) } /* Read Instruction Fault Address Register */ -static inline u32_t read_ifar() +static inline u32_t read_ifar(void) { u32_t far; @@ -273,7 +273,7 @@ static inline void write_ifar(u32_t far) } /* Read Vector Base Address Register */ -static inline u32_t read_vbar() +static inline u32_t read_vbar(void) { u32_t vbar; @@ -293,7 +293,7 @@ static inline void write_vbar(u32_t vbar) } /* Read the Main ID Register */ -static inline u32_t read_midr() +static inline u32_t read_midr(void) { u32_t id; @@ -304,7 +304,7 @@ static inline u32_t read_midr() } /* Read Auxiliary Control Register */ -static inline u32_t read_actlr() +static inline u32_t read_actlr(void) { u32_t ctl; @@ -324,7 +324,7 @@ static inline void write_actlr(u32_t ctl) } /* Read Current Program Status Register */ -static inline u32_t read_cpsr() +static inline u32_t read_cpsr(void) { u32_t status; diff --git a/kernel/arch/earm/memory.c b/kernel/arch/earm/memory.c index 9ff7acab6..81eb6c4dd 100644 --- a/kernel/arch/earm/memory.c +++ b/kernel/arch/earm/memory.c @@ -248,11 +248,10 @@ static u32_t phys_get32(phys_bytes addr) /*===========================================================================* * umap_virtual * *===========================================================================*/ -phys_bytes umap_virtual(rp, seg, vir_addr, bytes) -register struct proc *rp; /* pointer to proc table entry for process */ -int seg; /* T, D, or S segment */ -vir_bytes vir_addr; /* virtual address in bytes within the seg */ -vir_bytes bytes; /* # of bytes to be copied */ +phys_bytes umap_virtual(register struct proc *rp, /* process */ +int seg, /* T, D, or S segment */ +vir_bytes vir_addr, /* virtual address in bytes within the seg */ +vir_bytes bytes) /* # of bytes to be copied */ { phys_bytes phys = 0; @@ -290,20 +289,20 @@ vir_bytes bytes; /* # of bytes to be copied */ /*===========================================================================* * vm_lookup * *===========================================================================*/ -int vm_lookup(const struct proc *proc, const vir_bytes virtual, +int vm_lookup(const struct proc *whichproc, const vir_bytes virtual, phys_bytes *physical, u32_t *ptent) { u32_t *root, *pt; int pde, pte; u32_t pde_v, pte_v; - assert(proc); + assert(whichproc); assert(physical); - assert(!isemptyp(proc)); - assert(HASPT(proc)); + assert(!isemptyp(whichproc)); + assert(HASPT(whichproc)); /* Retrieve page directory entry. */ - root = (u32_t *) proc->p_seg.p_ttbr; + root = (u32_t *) whichproc->p_seg.p_ttbr; assert(!((u32_t) root % ARM_PAGEDIR_SIZE)); pde = ARM_VM_PDE(virtual); assert(pde >= 0 && pde < ARM_VM_DIR_ENTRIES); @@ -343,11 +342,12 @@ int vm_lookup(const struct proc *proc, const vir_bytes virtual, /*===========================================================================* * vm_lookup_range * *===========================================================================*/ -size_t vm_lookup_range(const struct proc *proc, vir_bytes vir_addr, +size_t vm_lookup_range(const struct proc *whichproc, vir_bytes vir_addr, phys_bytes *phys_addr, size_t bytes) { /* Look up the physical address corresponding to linear virtual address - * 'vir_addr' for process 'proc'. Return the size of the range covered + * 'vir_addr' for process 'whichproc'. + * Return the size of the range covered * by contiguous physical memory starting from that address; this may * be anywhere between 0 and 'bytes' inclusive. If the return value is * nonzero, and 'phys_addr' is non-NULL, 'phys_addr' will be set to the @@ -358,12 +358,12 @@ size_t vm_lookup_range(const struct proc *proc, vir_bytes vir_addr, phys_bytes phys, next_phys; size_t len; - assert(proc); + assert(whichproc); assert(bytes > 0); - assert(HASPT(proc)); + assert(HASPT(whichproc)); /* Look up the first page. */ - if (vm_lookup(proc, vir_addr, &phys, NULL) != OK) + if (vm_lookup(whichproc, vir_addr, &phys, NULL) != OK) return 0; if (phys_addr != NULL) @@ -375,7 +375,7 @@ size_t vm_lookup_range(const struct proc *proc, vir_bytes vir_addr, /* Look up any next pages and test physical contiguity. */ while (len < bytes) { - if (vm_lookup(proc, vir_addr, &phys, NULL) != OK) + if (vm_lookup(whichproc, vir_addr, &phys, NULL) != OK) break; if (next_phys != phys) @@ -541,12 +541,12 @@ int vm_memset(struct proc* caller, endpoint_t who, phys_bytes ph, int c, /*===========================================================================* * virtual_copy_f * *===========================================================================*/ -int virtual_copy_f(caller, src_addr, dst_addr, bytes, vmcheck) -struct proc * caller; -struct vir_addr *src_addr; /* source virtual address */ -struct vir_addr *dst_addr; /* destination virtual address */ -vir_bytes bytes; /* # of bytes to copy */ -int vmcheck; /* if nonzero, can return VMSUSPEND */ +int virtual_copy_f( +struct proc * caller, +struct vir_addr *src_addr, /* source virtual address */ +struct vir_addr *dst_addr, /* destination virtual address */ +vir_bytes bytes, /* # of bytes to copy */ +int vmcheck) /* if nonzero, can return VMSUSPEND */ { /* Copy bytes from virtual address src_addr to virtual address dst_addr. */ struct vir_addr *vir_addr[2]; /* virtual source and destination address */ @@ -685,7 +685,7 @@ static int frclock_index = -1, /* defined in kernel.lds */ extern char usermapped_start, usermapped_end, usermapped_nonglo_start; -int arch_phys_map(const int index, +int arch_phys_map(const int mindex, phys_bytes *addr, phys_bytes *len, int *flags) @@ -719,20 +719,20 @@ int arch_phys_map(const int index, } - if(index == usermapped_glo_index) { + if(mindex == usermapped_glo_index) { *addr = vir2phys(&usermapped_start); *len = glo_len; *flags = VMMF_USER | VMMF_GLO; return OK; } - else if(index == usermapped_index) { + else if(mindex == usermapped_index) { *addr = vir2phys(&usermapped_nonglo_start); *len = (u32_t) &usermapped_end - (u32_t) &usermapped_nonglo_start; *flags = VMMF_USER; return OK; } - else if (index == frclock_index) { + else if (mindex == frclock_index) { #ifdef DM37XX *addr = OMAP3_GPTIMER10_BASE; @@ -748,7 +748,7 @@ int arch_phys_map(const int index, /* list over the maps and index them */ phys_maps = kern_phys_map_head; while(phys_maps != NULL){ - if(phys_maps->index == index){ + if(phys_maps->index == mindex){ *addr = phys_maps->addr; *len = phys_maps->size; *flags = VMMF_UNCACHED | VMMF_WRITE; @@ -760,11 +760,11 @@ int arch_phys_map(const int index, return EINVAL; } -int arch_phys_map_reply(const int index, const vir_bytes addr) +int arch_phys_map_reply(const int mindex, const vir_bytes addr) { kern_phys_map *phys_maps; - if(index == first_um_idx) { + if(mindex == first_um_idx) { u32_t usermapped_offset; assert(addr > (u32_t) &usermapped_start); usermapped_offset = addr - (u32_t) &usermapped_start; @@ -786,10 +786,10 @@ int arch_phys_map_reply(const int index, const vir_bytes addr) return OK; } - if (index == usermapped_index) { + if (mindex == usermapped_index) { return OK; } - else if (index == frclock_index) { + else if (mindex == frclock_index) { #if defined(DM37XX) minix_kerninfo.minix_frclock_tcrr = addr + OMAP3_TIMER_TCRR; minix_kerninfo.minix_arm_frclock_hz = 1625000; @@ -807,7 +807,7 @@ int arch_phys_map_reply(const int index, const vir_bytes addr) /* list over the maps and index them */ phys_maps = kern_phys_map_head; while(phys_maps != NULL){ - if(phys_maps->index == index){ + if(phys_maps->index == mindex){ assert(phys_maps->cb != NULL); /* only update the vir addr we are going to call the callback in enable @@ -857,7 +857,7 @@ void release_address_space(struct proc *pr) * Request a physical mapping */ int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, - kern_phys_map * priv, kern_phys_map_mapped cb, + kern_phys_map * prv, kern_phys_map_mapped cb, vir_bytes id) { /* Assign the values to the given struct and add priv @@ -866,24 +866,24 @@ int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, assert(io_size % ARM_PAGE_SIZE == 0); assert(cb != NULL); - priv->addr = base_address; - priv->size = io_size; - priv->cb = cb; - priv->id = id; - priv->index = -1; - priv->next = NULL; + prv->addr = base_address; + prv->size = io_size; + prv->cb = cb; + prv->id = id; + prv->index = -1; + prv->next = NULL; if (kern_phys_map_head == NULL){ /* keep a list of items this is the first one */ - kern_phys_map_head = priv; + kern_phys_map_head = prv; kern_phys_map_head->next = NULL; } else { /* insert the item head but first keep track of the current by putting it in next */ - priv->next = kern_phys_map_head; + prv->next = kern_phys_map_head; /* replace the head */ - kern_phys_map_head = priv; + kern_phys_map_head = prv; } return 0; } @@ -893,7 +893,7 @@ int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size, * kern_phys_map is a pointer to the io map base address. * this implementation will change that base address. */ -int kern_phys_map_mapped_ptr(vir_bytes id, phys_bytes address){ +static int kern_phys_map_mapped_ptr(vir_bytes id, phys_bytes address){ *((vir_bytes*)id) = address; return 0; } @@ -905,9 +905,9 @@ int kern_phys_map_mapped_ptr(vir_bytes id, phys_bytes address){ int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size, - kern_phys_map * priv, + kern_phys_map * prv, vir_bytes ptr) { - return kern_req_phys_map(base_address,io_size,priv,kern_phys_map_mapped_ptr,ptr); + return kern_req_phys_map(base_address,io_size,prv,kern_phys_map_mapped_ptr,ptr); } diff --git a/kernel/arch/earm/omap_serial.c b/kernel/arch/earm/omap_serial.c index 3d182ef71..9775e49ea 100644 --- a/kernel/arch/earm/omap_serial.c +++ b/kernel/arch/earm/omap_serial.c @@ -41,7 +41,8 @@ static kern_phys_map serial_phys_map; * The serial driver also gets used in the "pre_init" stage before the kernel is loaded * in high memory so keep in mind there are two copies of this code in the kernel. */ -void omap3_ser_init(){ +void omap3_ser_init(void) +{ #ifdef DM37XX omap_serial.base = OMAP3_DM37XX_DEBUG_UART_BASE; #endif diff --git a/kernel/arch/earm/omap_serial.h b/kernel/arch/earm/omap_serial.h index 84272a2fa..31c8d9805 100644 --- a/kernel/arch/earm/omap_serial.h +++ b/kernel/arch/earm/omap_serial.h @@ -19,7 +19,7 @@ #ifndef __ASSEMBLY__ -void omap3_ser_init(); +void omap3_ser_init(void); void omap3_ser_putc(char c); #endif /* __ASSEMBLY__ */ diff --git a/kernel/arch/earm/omap_timer.c b/kernel/arch/earm/omap_timer.c index 748635368..bb1ffabae 100644 --- a/kernel/arch/earm/omap_timer.c +++ b/kernel/arch/earm/omap_timer.c @@ -203,7 +203,7 @@ void omap3_frclock_init(void) done = 1; } -void omap3_frclock_stop() +void omap3_frclock_stop(void) { mmio_clear(fr_timer.base + fr_timer.regs->TCLR, OMAP3_TCLR_ST); } @@ -254,7 +254,7 @@ void omap3_timer_init(unsigned freq) OMAP3_TCLR_OVF_TRG|OMAP3_TCLR_AR|OMAP3_TCLR_ST); } -void omap3_timer_stop() +void omap3_timer_stop(void) { mmio_clear(timer.base + timer.regs->TCLR, OMAP3_TCLR_ST); } @@ -277,7 +277,7 @@ static void frc_overflow_check(void) prev_frc_valid = 1; } -void omap3_timer_int_handler() +void omap3_timer_int_handler(void) { /* Clear all interrupts */ u32_t tisr; diff --git a/kernel/arch/earm/pg_utils.c b/kernel/arch/earm/pg_utils.c index b2f383e69..b1955d23d 100644 --- a/kernel/arch/earm/pg_utils.c +++ b/kernel/arch/earm/pg_utils.c @@ -21,6 +21,7 @@ static phys_bytes kern_kernlen = (phys_bytes) &_kern_size; /* page directory we can use to map things */ static u32_t pagedir[4096] __aligned(16384); +#if 0 void print_memmap(kinfo_t *cbi) { int m; @@ -31,6 +32,7 @@ void print_memmap(kinfo_t *cbi) } printf("\nsize %08lx\n", cbi->mmap_size); } +#endif void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end) { @@ -102,7 +104,7 @@ void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len) panic("no available memmap slot"); } -u32_t *alloc_pagetable(phys_bytes *ph) +static u32_t *alloc_pagetable(phys_bytes *ph) { u32_t *ret; #define PG_PAGETABLES 24 @@ -117,7 +119,7 @@ u32_t *alloc_pagetable(phys_bytes *ph) #define PAGE_KB (ARM_PAGE_SIZE / 1024) -phys_bytes pg_alloc_page(kinfo_t *cbi) +static phys_bytes pg_alloc_page(kinfo_t *cbi) { int m; multiboot_memory_map_t *mmap; @@ -210,7 +212,7 @@ void vm_enable_paging(void) write_sctlr(sctlr); } -phys_bytes pg_load() +phys_bytes pg_load(void) { phys_bytes phpagedir = vir2phys(pagedir); write_ttbr0(phpagedir); @@ -222,7 +224,7 @@ void pg_clear(void) memset(pagedir, 0, sizeof(pagedir)); } -phys_bytes pg_rounddown(phys_bytes b) +static phys_bytes pg_rounddown(phys_bytes b) { phys_bytes o; if(!(o = b % ARM_PAGE_SIZE)) diff --git a/kernel/arch/earm/protect.c b/kernel/arch/earm/protect.c index 75b3ef897..0e69404f1 100644 --- a/kernel/arch/earm/protect.c +++ b/kernel/arch/earm/protect.c @@ -47,7 +47,7 @@ int tss_init(unsigned cpu, void * kernel_stack) return 0; } -multiboot_module_t *bootmod(int pnr) +static multiboot_module_t *bootmod(int pnr) { int i; @@ -58,7 +58,7 @@ multiboot_module_t *bootmod(int pnr) * to a module, however, so we don't search those. */ for(i = NR_TASKS; i < NR_BOOT_PROCS; i++) { - int p; + unsigned int p; p = i - NR_TASKS; if(image[i].proc_nr == pnr) { assert(p < MULTIBOOT_MAX_MODS); @@ -72,7 +72,7 @@ multiboot_module_t *bootmod(int pnr) int booting_cpu = 0; -void prot_init() +void prot_init(void) { write_vbar((reg_t)&exc_vector_table); @@ -100,7 +100,7 @@ void arch_post_init(void) pg_info(&vm->p_seg.p_ttbr, &vm->p_seg.p_ttbr_v); } -int libexec_pg_alloc(struct exec_info *execi, off_t vaddr, size_t len) +static int libexec_pg_alloc(struct exec_info *execi, off_t vaddr, size_t len) { pg_map(PG_ALLOCATEME, vaddr, vaddr+len, &kinfo); pg_load(); diff --git a/kernel/arch/i386/acpi.c b/kernel/arch/i386/acpi.c index 7770f336c..f97faa93a 100644 --- a/kernel/arch/i386/acpi.c +++ b/kernel/arch/i386/acpi.c @@ -43,7 +43,7 @@ static u16_t pm1b_cnt_blk = 0; static u16_t slp_typa = 0; static u16_t slp_typb = 0; -static int acpi_check_csum(struct acpi_sdt_header * tb, size_t size) +static int acpi_check_csum(struct acpi_sdt_header * tb, int size) { u8_t total = 0; int i; @@ -120,7 +120,7 @@ static int acpi_read_sdt_at(phys_bytes addr, return tb->length; } -phys_bytes acpi_get_table_base(const char * name) +static phys_bytes acpi_get_table_base(const char * name) { int i; @@ -133,7 +133,8 @@ phys_bytes acpi_get_table_base(const char * name) return (phys_bytes) NULL; } -size_t acpi_get_table_length(const char * name) +#if 0 +static size_t acpi_get_table_length(const char * name) { int i; @@ -145,13 +146,14 @@ size_t acpi_get_table_length(const char * name) return 0; } +#endif static void * acpi_madt_get_typed_item(struct acpi_madt_hdr * hdr, unsigned char type, unsigned idx) { u8_t * t, * end; - int i; + unsigned int i; t = (u8_t *) hdr + sizeof(struct acpi_madt_hdr); end = (u8_t *) hdr + hdr->hdr.length; @@ -235,7 +237,7 @@ static void acpi_init_poweroff(void) u8_t *end = NULL; struct acpi_fadt_header *fadt_header = NULL; struct acpi_rsdt * dsdt_header = NULL; - char *msg = NULL; + const char *msg = NULL; /* Everything used here existed since ACPI spec 1.0 */ /* So we can safely use them */ @@ -394,11 +396,6 @@ struct acpi_madt_lapic * acpi_get_lapic_next(void) return ret; } -void __k_unpaged_acpi_poweroff(void) -{ - /* NO OP poweroff symbol*/ -} - void acpi_poweroff(void) { if (pm1a_cnt_blk == 0) { diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index 9ec3190c2..22de24971 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -157,10 +157,12 @@ static u32_t lapic_tctr0, lapic_tctr1; static unsigned apic_imcrp; static const unsigned nlints = 0; -void arch_eoi(void) +#if 0 +static void arch_eoi(void) { apic_eoi(); } +#endif /* * FIXME this should be a cpulocal variable but there are some problems with @@ -187,7 +189,7 @@ static void ioapic_write(u32_t ioa_base, u8_t reg, u32_t val) } void lapic_microsec_sleep(unsigned count); -void apic_idt_init(const int reset); +void apic_idt_init(const int resetv); static void ioapic_enable_pin(vir_bytes ioapic_addr, int pin) { @@ -297,10 +299,12 @@ void ioapic_eoi(int irq) irq_8259_eoi(irq); } -void ioapic_set_id(u32_t addr, unsigned int id) +#if 0 +static void ioapic_set_id(u32_t addr, unsigned int id) { ioapic_write(addr, IOAPIC_ID, id << 24); } +#endif int ioapic_enable_all(void) { @@ -405,7 +409,7 @@ void ioapic_mask_irq(unsigned irq) irq_8259_mask(irq); } -unsigned int apicid(void) +static int apicid(void) { return lapic_read(LAPIC_ID) >> 24; } @@ -868,7 +872,7 @@ static void lapic_set_dummy_handlers(void) #endif /* Build descriptors for interrupt gates in IDT. */ -void apic_idt_init(const int reset) +void apic_idt_init(const int resetv) { u32_t val; @@ -876,7 +880,7 @@ void apic_idt_init(const int reset) */ int is_bsp; - if (reset) { + if (resetv) { idt_copy_vectors_pic(); idt_copy_vectors(gate_table_common); return; @@ -1173,7 +1177,7 @@ static eoi_method_t set_eoi_method(unsigned irq) return ioapic_eoi_level; } -void set_irq_redir_low(unsigned irq, u32_t * low) +static void set_irq_redir_low(unsigned irq, u32_t * low) { u32_t val = 0; diff --git a/kernel/arch/i386/arch_clock.c b/kernel/arch/i386/arch_clock.c index ba7af4d0f..48a5a2f01 100644 --- a/kernel/arch/i386/arch_clock.c +++ b/kernel/arch/i386/arch_clock.c @@ -376,10 +376,10 @@ short cpu_load(void) void busy_delay_ms(int ms) { - u64_t cycles = ms_2_cpu_time(ms), tsc0, tsc, tsc1; - read_tsc_64(&tsc0); - tsc1 = tsc0 + cycles; - do { read_tsc_64(&tsc); } while(tsc < tsc1); + u64_t cycles = ms_2_cpu_time(ms), ctsc0, ctsc, ctsc1; + read_tsc_64(&ctsc0); + ctsc1 = ctsc0 + cycles; + do { read_tsc_64(&ctsc); } while(ctsc < ctsc1); return; } diff --git a/kernel/arch/i386/arch_do_vmctl.c b/kernel/arch/i386/arch_do_vmctl.c index c6f36ec46..d9af3b294 100644 --- a/kernel/arch/i386/arch_do_vmctl.c +++ b/kernel/arch/i386/arch_do_vmctl.c @@ -36,9 +36,8 @@ static void setcr3(struct proc *p, u32_t cr3, u32_t *v) /*===========================================================================* * arch_do_vmctl * *===========================================================================*/ -int arch_do_vmctl(m_ptr, p) -register message *m_ptr; /* pointer to request message */ -struct proc *p; +int arch_do_vmctl(register message *m_ptr, /* pointer to request message */ + struct proc *p) { switch(m_ptr->SVMCTL_PARAM) { case VMCTL_GET_PDBR: diff --git a/kernel/arch/i386/arch_system.c b/kernel/arch/i386/arch_system.c index f14d32ae1..23b395221 100644 --- a/kernel/arch/i386/arch_system.c +++ b/kernel/arch/i386/arch_system.c @@ -286,7 +286,7 @@ void arch_init(void) /*===========================================================================* * do_ser_debug * *===========================================================================*/ -void do_ser_debug() +void do_ser_debug(void) { u8_t c, lsr; @@ -421,7 +421,7 @@ static void ser_debug(const int c) #if DEBUG_SERIAL -static void ser_dump_vfs() +static void ser_dump_vfs(void) { /* Notify VFS it has to generate stack traces. Kernel can't do that as * it's not aware of user space threads. @@ -487,14 +487,15 @@ void arch_ack_profile_clock(void) #endif -void arch_do_syscall(struct proc *proc) +void arch_do_syscall(struct proc *whichproc) { /* do_ipc assumes that it's running because of the current process */ - assert(proc == get_cpulocal_var(proc_ptr)); + assert(whichproc == get_cpulocal_var(proc_ptr)); /* Make the system call, for real this time. */ - assert(proc->p_misc_flags & MF_SC_DEFER); - proc->p_reg.retreg = - do_ipc(proc->p_defer.r1, proc->p_defer.r2, proc->p_defer.r3); + assert(whichproc->p_misc_flags & MF_SC_DEFER); + whichproc->p_reg.retreg = + do_ipc(whichproc->p_defer.r1, whichproc->p_defer.r2, + whichproc->p_defer.r3); } struct proc * arch_finish_switch_to_user(void) @@ -566,7 +567,7 @@ void arch_proc_setcontext(struct proc *p, struct stackframe_s *state, p->p_seg.p_kern_trap_style = trap_style; } -void restore_user_context(struct proc *p) +__dead void restore_user_context(struct proc *p) { int trap_style = p->p_seg.p_kern_trap_style; #if 0 diff --git a/kernel/arch/i386/arch_watchdog.c b/kernel/arch/i386/arch_watchdog.c index 4dd3dcc8d..3a5efd334 100644 --- a/kernel/arch/i386/arch_watchdog.c +++ b/kernel/arch/i386/arch_watchdog.c @@ -104,7 +104,7 @@ void arch_watchdog_stop(void) { } -void arch_watchdog_lockup(const struct nmi_frame * frame) +__dead void arch_watchdog_lockup(const struct nmi_frame * frame) { printf("KERNEL LOCK UP\n" "eax 0x%08x\n" @@ -177,9 +177,10 @@ static int intel_arch_watchdog_profile_init(const unsigned freq) } static struct arch_watchdog intel_arch_watchdog = { - /*.init = */ intel_arch_watchdog_init, - /*.reinit = */ intel_arch_watchdog_reinit, - /*.profile_init = */ intel_arch_watchdog_profile_init + .init = intel_arch_watchdog_init, + .reinit = intel_arch_watchdog_reinit, + .profile_init = intel_arch_watchdog_profile_init, + .resetval = 0 }; #define AMD_MSR_EVENT_SEL0 0xc0010000 @@ -231,7 +232,8 @@ static int amd_watchdog_profile_init(const unsigned freq) } static struct arch_watchdog amd_watchdog = { - /*.init = */ amd_watchdog_init, - /*.reinit = */ amd_watchdog_reinit, - /*.profile_init = */ amd_watchdog_profile_init + .init = amd_watchdog_init, + .reinit = amd_watchdog_reinit, + .profile_init = amd_watchdog_profile_init, + .resetval = 0 }; diff --git a/kernel/arch/i386/direct_tty_utils.c b/kernel/arch/i386/direct_tty_utils.c index eb8364bc9..5e96bab7f 100644 --- a/kernel/arch/i386/direct_tty_utils.c +++ b/kernel/arch/i386/direct_tty_utils.c @@ -24,7 +24,7 @@ extern char *video_mem; #define VIDOFFSET(line, col) ((line) * MULTIBOOT_CONSOLE_COLS * 2 + (col) * 2) #define VIDSIZE VIDOFFSET(MULTIBOOT_CONSOLE_LINES-1,MULTIBOOT_CONSOLE_COLS-1) -void direct_put_char(char c, int line, int col) +static void direct_put_char(char c, int line, int col) { int offset = VIDOFFSET(line, col); video_mem[offset] = c; diff --git a/kernel/arch/i386/do_readbios.c b/kernel/arch/i386/do_readbios.c index 3f162570f..b55801def 100644 --- a/kernel/arch/i386/do_readbios.c +++ b/kernel/arch/i386/do_readbios.c @@ -17,6 +17,7 @@ int do_readbios(struct proc * caller, message * m_ptr) { struct vir_addr src, dst; vir_bytes len = m_ptr->RDB_SIZE, limit; + phys_bytes biosbegin = BIOS_MEM_BEGIN; src.offset = m_ptr->RDB_ADDR; dst.offset = (vir_bytes) m_ptr->RDB_BUF; @@ -29,7 +30,7 @@ int do_readbios(struct proc * caller, message * m_ptr) #define SUBRANGE(a,b,c,d) (VINRANGE((a), (c), (d)) && VINRANGE((b),(c),(d))) #define USERRANGE(a, b) SUBRANGE(src.offset, limit, (a), (b)) - if(!USERRANGE(BIOS_MEM_BEGIN, BIOS_MEM_END) && + if(!USERRANGE(biosbegin, BIOS_MEM_END) && !USERRANGE(BASE_MEM_TOP, UPPER_MEM_END)) return EPERM; diff --git a/kernel/arch/i386/do_sdevio.c b/kernel/arch/i386/do_sdevio.c index 23ea4fa24..4c72b91bc 100644 --- a/kernel/arch/i386/do_sdevio.c +++ b/kernel/arch/i386/do_sdevio.c @@ -28,9 +28,10 @@ int do_sdevio(struct proc * caller, message *m_ptr) int proc_nr; endpoint_t proc_nr_e = m_ptr->DIO_VEC_ENDPT; vir_bytes count = m_ptr->DIO_VEC_SIZE; - long port = m_ptr->DIO_PORT; + port_t port = m_ptr->DIO_PORT; phys_bytes vir_buf; - int i, req_type, req_dir, size, nr_io_range; + int i, req_type, req_dir, nr_io_range; + unsigned int size; struct priv *privp; struct io_range *iorp; struct proc *destproc; diff --git a/kernel/arch/i386/exception.c b/kernel/arch/i386/exception.c index 08e73e419..cd3057d3f 100644 --- a/kernel/arch/i386/exception.c +++ b/kernel/arch/i386/exception.c @@ -11,7 +11,7 @@ #include struct ex_s { - char *msg; + const char *msg; int signum; int minprocessor; }; @@ -129,7 +129,7 @@ static void pagefault( struct proc *pr, return; } -static void inkernel_disaster(struct proc *saved_proc, +__dead static void inkernel_disaster(struct proc *saved_proc, struct exception_frame * frame, struct ex_s *ep, int is_nested) { diff --git a/kernel/arch/i386/include/arch_proto.h b/kernel/arch/i386/include/arch_proto.h index 3aa879096..dd2532f16 100644 --- a/kernel/arch/i386/include/arch_proto.h +++ b/kernel/arch/i386/include/arch_proto.h @@ -80,6 +80,7 @@ struct exception_frame { }; void exception(struct exception_frame * frame); +void exception_handler(int is_nested, struct exception_frame * frame); /* klib.S */ __dead void monitor(void); @@ -260,6 +261,9 @@ int platform_tbl_ptr(phys_bytes start, phys_bytes end, unsigned increment, void * buff, unsigned size, phys_bytes * phys_addr, int ((* cmp_f)(void *))); +/* pre_init.c */ +kinfo_t *pre_init(u32_t magic, u32_t ebx); + /* breakpoints.c */ int breakpoint_set(phys_bytes linaddr, int bp, const int flags); #define BREAKPOINT_COUNT 4 @@ -276,6 +280,10 @@ int breakpoint_set(phys_bytes linaddr, int bp, const int flags); #define BREAKPOINT_FLAG_MODE_LOCAL (1 << 4) #define BREAKPOINT_FLAG_MODE_GLOBAL (2 << 4) +/* apic.c */ +void apic_spurios_intr_handler(void); +void apic_error_intr_handler(void); + /* functions defined in architecture-independent kernel source. */ #include "kernel/proto.h" diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 943a26a7a..38b513e8b 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -276,11 +276,10 @@ static char *cr4_str(u32_t e) /*===========================================================================* * umap_virtual * *===========================================================================*/ -phys_bytes umap_virtual(rp, seg, vir_addr, bytes) -register struct proc *rp; /* pointer to proc table entry for process */ -int seg; /* T, D, or S segment */ -vir_bytes vir_addr; /* virtual address in bytes within the seg */ -vir_bytes bytes; /* # of bytes to be copied */ +phys_bytes umap_virtual(register struct proc *rp, /* pointer to process */ + int seg, /* T, D, or S segment */ + vir_bytes vir_addr, /* virtual address in bytes within the seg */ + vir_bytes bytes) /* # of bytes to be copied */ { phys_bytes phys = 0; @@ -318,20 +317,20 @@ vir_bytes bytes; /* # of bytes to be copied */ /*===========================================================================* * vm_lookup * *===========================================================================*/ -int vm_lookup(const struct proc *proc, const vir_bytes virtual, +int vm_lookup(const struct proc *whichproc, const vir_bytes virtual, phys_bytes *physical, u32_t *ptent) { u32_t *root, *pt; int pde, pte; u32_t pde_v, pte_v; - assert(proc); + assert(whichproc); assert(physical); - assert(!isemptyp(proc)); - assert(HASPT(proc)); + assert(!isemptyp(whichproc)); + assert(HASPT(whichproc)); /* Retrieve page directory entry. */ - root = (u32_t *) proc->p_seg.p_cr3; + root = (u32_t *) whichproc->p_seg.p_cr3; assert(!((u32_t) root % I386_PAGE_SIZE)); pde = I386_VM_PDE(virtual); assert(pde >= 0 && pde < I386_VM_DIR_ENTRIES); @@ -370,7 +369,7 @@ int vm_lookup(const struct proc *proc, const vir_bytes virtual, /*===========================================================================* * vm_lookup_range * *===========================================================================*/ -size_t vm_lookup_range(const struct proc *proc, vir_bytes vir_addr, +size_t vm_lookup_range(const struct proc *whichproc, vir_bytes vir_addr, phys_bytes *phys_addr, size_t bytes) { /* Look up the physical address corresponding to linear virtual address @@ -385,12 +384,12 @@ size_t vm_lookup_range(const struct proc *proc, vir_bytes vir_addr, phys_bytes phys, next_phys; size_t len; - assert(proc); + assert(whichproc); assert(bytes > 0); assert(HASPT(proc)); /* Look up the first page. */ - if (vm_lookup(proc, vir_addr, &phys, NULL) != OK) + if (vm_lookup(whichproc, vir_addr, &phys, NULL) != OK) return 0; if (phys_addr != NULL) @@ -402,7 +401,7 @@ size_t vm_lookup_range(const struct proc *proc, vir_bytes vir_addr, /* Look up any next pages and test physical contiguity. */ while (len < bytes) { - if (vm_lookup(proc, vir_addr, &phys, NULL) != OK) + if (vm_lookup(whichproc, vir_addr, &phys, NULL) != OK) break; if (next_phys != phys) @@ -644,12 +643,11 @@ int vm_memset(struct proc* caller, endpoint_t who, phys_bytes ph, int c, /*===========================================================================* * virtual_copy_f * *===========================================================================*/ -int virtual_copy_f(caller, src_addr, dst_addr, bytes, vmcheck) -struct proc * caller; -struct vir_addr *src_addr; /* source virtual address */ -struct vir_addr *dst_addr; /* destination virtual address */ -vir_bytes bytes; /* # of bytes to copy */ -int vmcheck; /* if nonzero, can return VMSUSPEND */ +int virtual_copy_f(struct proc * caller, + struct vir_addr *src_addr, /* source virtual address */ + struct vir_addr *dst_addr, /* destination virtual address */ + vir_bytes bytes, /* # of bytes to copy */ + int vmcheck) /* if nonzero, can return VMSUSPEND */ { /* Copy bytes from virtual address src_addr to virtual address dst_addr. */ struct vir_addr *vir_addr[2]; /* virtual source and destination address */ @@ -792,14 +790,14 @@ extern char *video_mem; extern char usermapped_start, usermapped_end, usermapped_nonglo_start; -int arch_phys_map(const int index, +int arch_phys_map(const int mindex, phys_bytes *addr, phys_bytes *len, int *flags) { static int first = 1; int freeidx = 0; - static char *ser_var = NULL; + static const char *ser_var = NULL; u32_t glo_len = (u32_t) &usermapped_nonglo_start - (u32_t) &usermapped_start; @@ -840,20 +838,20 @@ int arch_phys_map(const int index, first = 0; } - if(index == usermapped_glo_index) { + if(mindex == usermapped_glo_index) { *addr = vir2phys(&usermapped_start); *len = glo_len; *flags = VMMF_USER | VMMF_GLO; return OK; } - else if(index == usermapped_index) { + else if(mindex == usermapped_index) { *addr = vir2phys(&usermapped_nonglo_start); *len = (u32_t) &usermapped_end - (u32_t) &usermapped_nonglo_start; *flags = VMMF_USER; return OK; } - else if (index == video_mem_mapping_index) { + else if (mindex == video_mem_mapping_index) { /* map video memory in so we can print panic messages */ *addr = MULTIBOOT_VIDEO_BUFFER; *len = I386_PAGE_SIZE; @@ -861,7 +859,7 @@ int arch_phys_map(const int index, return OK; } #ifdef USE_APIC - else if (index == lapic_mapping_index) { + else if (mindex == lapic_mapping_index) { /* map the local APIC if enabled */ if (!lapic_addr) return EINVAL; @@ -870,8 +868,8 @@ int arch_phys_map(const int index, *flags = VMMF_UNCACHED | VMMF_WRITE; return OK; } - else if (ioapic_enabled && index >= ioapic_first_index && index <= ioapic_last_index) { - int ioapic_idx = index - ioapic_first_index; + else if (ioapic_enabled && mindex >= ioapic_first_index && mindex <= ioapic_last_index) { + int ioapic_idx = mindex - ioapic_first_index; *addr = io_apic[ioapic_idx].paddr; assert(*addr); *len = 4 << 10 /* 4kB */; @@ -882,7 +880,7 @@ int arch_phys_map(const int index, #endif #if CONFIG_OXPCIE - if(index == oxpcie_mapping_index) { + if(mindex == oxpcie_mapping_index) { *addr = strtoul(ser_var+2, NULL, 16); *len = 0x4000; *flags = VMMF_UNCACHED | VMMF_WRITE; @@ -893,29 +891,29 @@ int arch_phys_map(const int index, return EINVAL; } -int arch_phys_map_reply(const int index, const vir_bytes addr) +int arch_phys_map_reply(const int mindex, const vir_bytes addr) { #ifdef USE_APIC /* if local APIC is enabled */ - if (index == lapic_mapping_index && lapic_addr) { + if (mindex == lapic_mapping_index && lapic_addr) { lapic_addr_vaddr = addr; return OK; } - else if (ioapic_enabled && index >= ioapic_first_index && - index <= ioapic_last_index) { - int i = index - ioapic_first_index; + else if (ioapic_enabled && mindex >= ioapic_first_index && + mindex <= ioapic_last_index) { + int i = mindex - ioapic_first_index; io_apic[i].vaddr = addr; return OK; } #endif #if CONFIG_OXPCIE - if (index == oxpcie_mapping_index) { + if (mindex == oxpcie_mapping_index) { oxpcie_set_vaddr((unsigned char *) addr); return OK; } #endif - if(index == first_um_idx) { + if(mindex == first_um_idx) { extern struct minix_ipcvecs minix_ipcvecs_sysenter, minix_ipcvecs_syscall, minix_ipcvecs_softint; @@ -971,9 +969,9 @@ int arch_phys_map_reply(const int index, const vir_bytes addr) return OK; } - if(index == usermapped_index) return OK; + if(mindex == usermapped_index) return OK; - if (index == video_mem_mapping_index) { + if (mindex == video_mem_mapping_index) { video_mem_vaddr = addr; return OK; } @@ -1000,7 +998,7 @@ int arch_enable_paging(struct proc * caller) } /* if IO apics are enabled */ if (ioapic_enabled) { - int i; + unsigned int i; for (i = 0; i < nioapics; i++) { io_apic[i].addr = io_apic[i].vaddr; diff --git a/kernel/arch/i386/pg_utils.c b/kernel/arch/i386/pg_utils.c index 91e4fab7a..642881390 100644 --- a/kernel/arch/i386/pg_utils.c +++ b/kernel/arch/i386/pg_utils.c @@ -18,7 +18,8 @@ static phys_bytes kern_kernlen = (phys_bytes) &_kern_size; /* page directory we can use to map things */ static u32_t pagedir[1024] __aligned(4096); -void print_memmap(kinfo_t *cbi) +#if 0 +static void print_memmap(kinfo_t *cbi) { int m; assert(cbi->mmap_size < MAXMEMMAP); @@ -28,6 +29,7 @@ void print_memmap(kinfo_t *cbi) } printf("\nsize %08lx\n", cbi->mmap_size); } +#endif void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end) { @@ -120,7 +122,7 @@ void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len) panic("no available memmap slot"); } -u32_t *alloc_pagetable(phys_bytes *ph) +static u32_t *alloc_pagetable(phys_bytes *ph) { u32_t *ret; #define PG_PAGETABLES 6 @@ -135,7 +137,7 @@ u32_t *alloc_pagetable(phys_bytes *ph) #define PAGE_KB (I386_PAGE_SIZE / 1024) -phys_bytes pg_alloc_page(kinfo_t *cbi) +static phys_bytes pg_alloc_page(kinfo_t *cbi) { int m; multiboot_memory_map_t *mmap; @@ -239,7 +241,7 @@ void vm_enable_paging(void) write_cr4(cr4); } -phys_bytes pg_load() +phys_bytes pg_load(void) { phys_bytes phpagedir = vir2phys(pagedir); write_cr3(phpagedir); @@ -251,7 +253,7 @@ void pg_clear(void) memset(pagedir, 0, sizeof(pagedir)); } -phys_bytes pg_rounddown(phys_bytes b) +static phys_bytes pg_rounddown(phys_bytes b) { phys_bytes o; if(!(o = b % I386_PAGE_SIZE)) diff --git a/kernel/arch/i386/pre_init.c b/kernel/arch/i386/pre_init.c index d63575e48..0813a6afb 100644 --- a/kernel/arch/i386/pre_init.c +++ b/kernel/arch/i386/pre_init.c @@ -1,8 +1,10 @@ #define UNPAGED 1 /* for proper kmain() prototype */ +#include "acpi.h" #include "kernel/kernel.h" #include +#include #include #include #include @@ -39,7 +41,7 @@ char *video_mem = (char *) MULTIBOOT_VIDEO_BUFFER; /* Kernel may use memory */ int kernel_may_alloc = 1; -static int mb_set_param(char *bigbuf, char *name, char *value, kinfo_t *cbi) +static int mb_set_param(char *bigbuf, const char *name, const char *value, kinfo_t *cbi) { char *p = bigbuf; char *bufend = bigbuf + MULTIBOOT_PARAM_BUF_SIZE; @@ -81,7 +83,7 @@ static int mb_set_param(char *bigbuf, char *name, char *value, kinfo_t *cbi) return 0; } -int overlaps(multiboot_module_t *mod, int n, int cmp_mod) +static int overlaps(multiboot_module_t *mod, int n, int cmp_mod) { multiboot_module_t *cmp = &mod[cmp_mod]; int m; @@ -98,7 +100,7 @@ int overlaps(multiboot_module_t *mod, int n, int cmp_mod) return 0; } -void get_parameters(u32_t ebx, kinfo_t *cbi) +static void get_parameters(u32_t ebx, kinfo_t *cbi) { multiboot_memory_map_t *mmap; multiboot_info_t *mbi = &cbi->mbi; @@ -247,3 +249,4 @@ int send_sig(endpoint_t proc_nr, int sig_nr) { return 0; } void minix_shutdown(timer_t *t) { arch_shutdown(RBT_PANIC); } void busy_delay_ms(int x) { } int raise(int sig) { panic("raise(%d)\n", sig); } +__dead void acpi_poweroff(void) { while(1) ; } diff --git a/kernel/arch/i386/protect.c b/kernel/arch/i386/protect.c index 5a98a41ad..b65f3e44a 100644 --- a/kernel/arch/i386/protect.c +++ b/kernel/arch/i386/protect.c @@ -55,7 +55,7 @@ void enable_iop(struct proc *pp) /*===========================================================================* * sdesc * *===========================================================================*/ - void sdesc(struct segdesc_s *segdp, phys_bytes base, vir_bytes size) +static void sdesc(struct segdesc_s *segdp, phys_bytes base, vir_bytes size) { /* Fill in the size fields (base, limit and granularity) of a descriptor. */ segdp->base_low = base; @@ -77,7 +77,7 @@ void enable_iop(struct proc *pp) /*===========================================================================* * init_dataseg * *===========================================================================*/ -void init_param_dataseg(register struct segdesc_s *segdp, +static void init_param_dataseg(register struct segdesc_s *segdp, phys_bytes base, vir_bytes size, const int privilege) { /* Build descriptor for a data segment. */ @@ -87,19 +87,19 @@ void init_param_dataseg(register struct segdesc_s *segdp, /* EXECUTABLE = 0, EXPAND_DOWN = 0, ACCESSED = 0 */ } -void init_dataseg(int index, const int privilege) +static void init_dataseg(int dindex, const int privilege) { - init_param_dataseg(&gdt[index], 0, 0xFFFFFFFF, privilege); + init_param_dataseg(&gdt[dindex], 0, 0xFFFFFFFF, privilege); } /*===========================================================================* * init_codeseg * *===========================================================================*/ -static void init_codeseg(int index, int privilege) +static void init_codeseg(int cindex, int privilege) { /* Build descriptor for a code segment. */ - sdesc(&gdt[index], 0, 0xFFFFFFFF); - gdt[index].access = (privilege << DPL_SHIFT) + sdesc(&gdt[cindex], 0, 0xFFFFFFFF); + gdt[cindex].access = (privilege << DPL_SHIFT) | (PRESENT | SEGMENT | EXECUTABLE | READABLE); /* CONFORMING = 0, ACCESSED = 0 */ } @@ -154,10 +154,10 @@ static struct gate_table_s gate_table_exceptions[] = { int tss_init(unsigned cpu, void * kernel_stack) { struct tss_s * t = &tss[cpu]; - int index = TSS_INDEX(cpu); + int tindex = TSS_INDEX(cpu); struct segdesc_s *tssgdt; - tssgdt = &gdt[index]; + tssgdt = &gdt[tindex]; init_param_dataseg(tssgdt, (phys_bytes) t, sizeof(struct tss_s), INTR_PRIVILEGE); @@ -212,10 +212,11 @@ int tss_init(unsigned cpu, void * kernel_stack) assert(CONFIG_MAX_CPUS <= 8); } - return SEG_SELECTOR(index); + return SEG_SELECTOR(tindex); } -phys_bytes init_segdesc(int gdt_index, void *base, int size) +#if 0 +static phys_bytes init_segdesc(int gdt_index, void *base, int size) { struct desctableptr_s *dtp = (struct desctableptr_s *) &gdt[gdt_index]; dtp->limit = size - 1; @@ -223,8 +224,9 @@ phys_bytes init_segdesc(int gdt_index, void *base, int size) return (phys_bytes) dtp; } +#endif -void int_gate(struct gatedesc_s *tab, +static void int_gate(struct gatedesc_s *tab, unsigned vec_nr, vir_bytes offset, unsigned dpl_type) { /* Build descriptor for an interrupt gate. */ @@ -257,7 +259,7 @@ void idt_copy_vectors_pic(void) idt_copy_vectors(gate_table_pic); } -void idt_init(void) +static void idt_init(void) { idt_copy_vectors_pic(); idt_copy_vectors(gate_table_exceptions); @@ -270,7 +272,7 @@ void idt_reload(void) x86_lidt(&idt_desc); } -multiboot_module_t *bootmod(int pnr) +static multiboot_module_t *bootmod(int pnr) { int i; @@ -284,8 +286,8 @@ multiboot_module_t *bootmod(int pnr) int p; p = i - NR_TASKS; if(image[i].proc_nr == pnr) { - assert(p < MULTIBOOT_MAX_MODS); - assert(p < kinfo.mbi.mods_count); + assert(p < (int) MULTIBOOT_MAX_MODS); + assert(p < (int) kinfo.mbi.mods_count); return &kinfo.module_list[p]; } } @@ -295,7 +297,7 @@ multiboot_module_t *bootmod(int pnr) int booting_cpu = 0; -void prot_load_selectors(void) +static void prot_load_selectors(void) { /* this function is called by both prot_init by the BSP and * the early AP booting code in mpx.S by secondary CPU's. @@ -318,7 +320,7 @@ void prot_load_selectors(void) /*===========================================================================* * prot_init * *===========================================================================*/ -void prot_init() +void prot_init(void) { extern char k_boot_stktop; @@ -376,7 +378,7 @@ void arch_post_init(void) pg_info(&vm->p_seg.p_cr3, &vm->p_seg.p_cr3_v); } -int libexec_pg_alloc(struct exec_info *execi, off_t vaddr, size_t len) +static int libexec_pg_alloc(struct exec_info *execi, off_t vaddr, size_t len) { pg_map(PG_ALLOCATEME, vaddr, vaddr+len, &kinfo); pg_load(); diff --git a/kernel/clock.c b/kernel/clock.c index be6cfa572..c1d7e0f34 100644 --- a/kernel/clock.c +++ b/kernel/clock.c @@ -212,23 +212,21 @@ clock_t get_monotonic(void) /*===========================================================================* * set_timer * *===========================================================================*/ -void set_timer(tp, exp_time, watchdog) -struct timer *tp; /* pointer to timer structure */ -clock_t exp_time; /* expiration monotonic time */ -tmr_func_t watchdog; /* watchdog to be called */ +void set_timer(struct timer *tp, /* pointer to timer structure */ + clock_t exp_time, /* expiration monotonic time */ + tmr_func_t watchdog_func) /* watchdog to be called */ { /* Insert the new timer in the active timers list. Always update the * next timeout time by setting it to the front of the active list. */ - tmrs_settimer(&clock_timers, tp, exp_time, watchdog, NULL); + tmrs_settimer(&clock_timers, tp, exp_time, watchdog_func, NULL); next_timeout = clock_timers->tmr_exp_time; } /*===========================================================================* * reset_timer * *===========================================================================*/ -void reset_timer(tp) -struct timer *tp; /* pointer to timer structure */ +void reset_timer(struct timer *tp) /* pointer to timer structure */ { /* The timer pointed to by 'tp' is no longer needed. Remove it from both the * active and expired lists. Always update the next timeout time by setting diff --git a/kernel/debug.c b/kernel/debug.c index 751d17a6b..4f194eddf 100644 --- a/kernel/debug.c +++ b/kernel/debug.c @@ -14,7 +14,7 @@ #define MAX_LOOP (NR_PROCS + NR_TASKS) -int runqueues_ok_cpu(unsigned cpu) +static int runqueues_ok_cpu(unsigned cpu) { int q, l = 0; register struct proc *xp; @@ -134,7 +134,7 @@ int runqueues_ok(void) #endif -char * +const char * rtsflagstr(const u32_t flags) { static char str[100]; @@ -161,7 +161,7 @@ rtsflagstr(const u32_t flags) return str; } -char * +const char * miscflagstr(const u32_t flags) { static char str[100]; @@ -174,7 +174,7 @@ miscflagstr(const u32_t flags) return str; } -char * +const char * schedulerstr(struct proc *scheduler) { if (scheduler != NULL) diff --git a/kernel/glo.h b/kernel/glo.h index 8664a0d1b..b7bbb273b 100644 --- a/kernel/glo.h +++ b/kernel/glo.h @@ -35,7 +35,7 @@ vir_bytes minix_kerninfo_user; /* Process scheduling information and the kernel reentry count. */ EXTERN struct proc *vmrequest; /* first process on vmrequest queue */ EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */ -EXTERN char *ipc_call_names[IPCNO_HIGHEST+1]; /* human-readable call names */ +EXTERN const char *ipc_call_names[IPCNO_HIGHEST+1]; /* human call names */ EXTERN struct proc *kbill_kcall; /* process that made kernel call */ EXTERN struct proc *kbill_ipc; /* process that invoked ipc */ diff --git a/kernel/main.c b/kernel/main.c index 78b74a2c3..b4e0add64 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -37,7 +37,7 @@ char *** _penviron; /* Prototype declarations for PRIVATE functions. */ static void announce(void); -void bsp_finish_booting(void) +__dead void bsp_finish_booting(void) { int i; #if SPROFILE @@ -118,12 +118,12 @@ void bsp_finish_booting(void) /*===========================================================================* * kmain * *===========================================================================*/ -void kmain(kinfo_t *local_cbi) +__dead void kmain(kinfo_t *local_cbi) { /* Start the ball rolling. */ struct boot_image *ip; /* boot image pointer */ register struct proc *rp; /* process pointer */ - register int i, j; + unsigned int i, j; /* save a global copy of the boot parameters */ memcpy(&kinfo, local_cbi, sizeof(kinfo)); @@ -399,12 +399,12 @@ void minix_shutdown(timer_t *tp) /*===========================================================================* * cstart * *===========================================================================*/ -void cstart() +void cstart(void) { /* Perform system initializations prior to calling main(). Most settings are * determined with help of the environment strings passed by MINIX' loader. */ - register char *value; /* value in key=value pair */ + register const char *value; /* value in key=value pair */ int h; /* low-level initialization */ @@ -473,7 +473,7 @@ void cstart() * get_value * *===========================================================================*/ -char *get_value( +static const char *get_value( const char *params, /* boot monitor parameters */ const char *name /* key to look up */ ) @@ -482,9 +482,9 @@ char *get_value( * usual environment array. */ register const char *namep; - register char *envp; + register const char *envp; - for (envp = (char *) params; *envp != 0;) { + for (envp = params; *envp != 0;) { for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++) ; if (*namep == '\0' && *envp == '=') return(envp + 1); @@ -497,7 +497,7 @@ char *get_value( /*===========================================================================* * env_get * *===========================================================================*/ -char *env_get(const char *name) +const char *env_get(const char *name) { return get_value(kinfo.param_buf, name); } diff --git a/kernel/proc.c b/kernel/proc.c index 9a1c3e115..d3a5eae15 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -226,7 +226,7 @@ static void idle(void) /*===========================================================================* * switch_to_user * *===========================================================================*/ -void switch_to_user(void) +__dead void switch_to_user(void) { /* This function is called an instant before proc_ptr is * to be scheduled again. @@ -413,7 +413,7 @@ static int do_sync_ipc(struct proc * caller_ptr, /* who made the call */ { int result; /* the system call's result */ int src_dst_p; /* Process slot number */ - char *callname; + const char *callname; /* Check destination. RECEIVE is the only call that accepts ANY (in addition * to a real endpoint). The other calls (SEND, SENDREC, and NOTIFY) require an @@ -630,10 +630,8 @@ int do_ipc(reg_t r1, reg_t r2, reg_t r3) /*===========================================================================* * deadlock * *===========================================================================*/ -static int deadlock(function, cp, src_dst_e) -int function; /* trap number */ -register struct proc *cp; /* pointer to caller */ -endpoint_t src_dst_e; /* src or dst process */ +static int deadlock(int function, register struct proc *cp, + endpoint_t src_dst_e) { /* 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 @@ -1282,8 +1280,7 @@ static int mini_senda(struct proc *caller_ptr, asynmsg_t *table, size_t size) /*===========================================================================* * try_async * *===========================================================================*/ -static int try_async(caller_ptr) -struct proc *caller_ptr; +static int try_async(struct proc *caller_ptr) { int r; struct priv *privp; @@ -1752,15 +1749,10 @@ struct proc *endpoint_lookup(endpoint_t e) * isokendpt_f * *===========================================================================*/ #if DEBUG_ENABLE_IPC_WARNINGS -int isokendpt_f(file, line, e, p, fatalflag) -const char *file; -int line; +int isokendpt_f(const char *file, int line, endpoint_t e, int *p, const int fatalflag) #else -int isokendpt_f(e, p, fatalflag) +int isokendpt_f(endpoint_t e, int *p, const int fatalflag) #endif -endpoint_t e; -int *p; -const int fatalflag; { int ok = 0; /* Convert an endpoint number into a process number. @@ -1895,7 +1887,7 @@ void release_fpu(struct proc * p) { *fpu_owner_ptr = NULL; } -void ser_dump_proc() +void ser_dump_proc(void) { struct proc *pp; diff --git a/kernel/proto.h b/kernel/proto.h index e59c54d6c..e88aecab8 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -47,6 +47,7 @@ void kmain(kinfo_t *cbi); void prepare_shutdown(int how); __dead void minix_shutdown(struct timer *tp); void bsp_finish_booting(void); +void cstart(void); /* proc.c */ @@ -79,10 +80,11 @@ void increase_proc_signals(struct proc *p); void flag_account(struct proc *p, int flag); int try_deliver_senda(struct proc *caller_ptr, asynmsg_t *table, size_t size); +void copr_not_available_handler(void); /* start.c */ -void cstart(); -char *env_get(const char *key); +void cstart(void); +const char *env_get(const char *key); /* system.c */ int get_priv(register struct proc *rc, int proc_type); @@ -119,9 +121,9 @@ int runqueues_ok(void); #define runqueues_ok_local() runqueues_ok_cpu(cpuid) int runqueues_ok_cpu(unsigned cpu); #endif -char *rtsflagstr(u32_t flags); -char *miscflagstr(u32_t flags); -char *schedulerstr(struct proc *scheduler); +const char *rtsflagstr(u32_t flags); +const char *miscflagstr(u32_t flags); +const char *schedulerstr(struct proc *scheduler); /* prints process information */ void print_proc(struct proc *pp); /* prints the given process and recursively all processes it depends on */ @@ -148,8 +150,8 @@ void stop_profile_clock(void); #endif /* functions defined in architecture-dependent files. */ -void prot_init(); -void arch_post_init(); +void prot_init(void); +void arch_post_init(void); void arch_set_secondary_ipc_return(struct proc *, u32_t val); phys_bytes phys_copy(phys_bytes source, phys_bytes dest, phys_bytes count); diff --git a/kernel/system.c b/kernel/system.c index 3f2705ded..b7da6ac3d 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -272,9 +272,7 @@ void system_init(void) /*===========================================================================* * get_priv * *===========================================================================*/ -int get_priv(rc, priv_id) -register struct proc *rc; /* new (child) process pointer */ -int priv_id; /* privilege id */ +int get_priv(register struct proc *rc, int priv_id) { /* Allocate a new privilege structure for a system process. Privilege ids * can be assigned either statically or dynamically. @@ -368,16 +366,16 @@ int send_sig(endpoint_t ep, int sig_nr) * send a notification with source SYSTEM. */ register struct proc *rp; - struct priv *priv; + struct priv *privs; int proc_nr; if(!isokendpt(ep, &proc_nr) || isemptyn(proc_nr)) return EINVAL; rp = proc_addr(proc_nr); - priv = priv(rp); - if(!priv) return ENOENT; - sigaddset(&priv->s_sig_pending, sig_nr); + privs = priv(rp); + if(!privs) return ENOENT; + sigaddset(&privs->s_sig_pending, sig_nr); increase_proc_signals(rp); mini_notify(proc_addr(SYSTEM), rp->p_endpoint); @@ -387,9 +385,7 @@ int send_sig(endpoint_t ep, int sig_nr) /*===========================================================================* * cause_sig * *===========================================================================*/ -void cause_sig(proc_nr, sig_nr) -proc_nr_t proc_nr; /* process to be signalled */ -int sig_nr; /* signal to be sent */ +void cause_sig(proc_nr_t proc_nr, int sig_nr) { /* A system process wants to send a signal to a process. Examples are: * - HARDWARE wanting to cause a SIGSEGV after a CPU exception @@ -498,8 +494,7 @@ static void clear_ipc( /*===========================================================================* * clear_endpoint * *===========================================================================*/ -void clear_endpoint(rc) -register struct proc *rc; /* slot of process to clean up */ +void clear_endpoint(struct proc *rc) { if(isemptyp(rc)) panic("clear_proc: empty process: %d", rc->p_endpoint); @@ -531,9 +526,7 @@ register struct proc *rc; /* slot of process to clean up */ /*===========================================================================* * clear_ipc_refs * *===========================================================================*/ -void clear_ipc_refs(rc, caller_ret) -register struct proc *rc; /* slot of process to clean up */ -int caller_ret; /* code to return on callers */ +void clear_ipc_refs(register struct proc *rc, int caller_ret) { /* Clear IPC references for a given process slot. */ struct proc *rp; /* iterate over process table */ diff --git a/kernel/system/do_devio.c b/kernel/system/do_devio.c index 722e6c100..40579f96d 100644 --- a/kernel/system/do_devio.c +++ b/kernel/system/do_devio.c @@ -22,8 +22,8 @@ int do_devio(struct proc * caller, message * m_ptr) struct priv *privp; port_t port; struct io_range *iorp; - int i, size, nr_io_range; - int io_type, io_dir; + unsigned int i, size, nr_io_range; + unsigned int io_type, io_dir; io_type = m_ptr->DIO_REQUEST & _DIO_TYPEMASK; io_dir = m_ptr->DIO_REQUEST & _DIO_DIRMASK; diff --git a/kernel/system/do_getinfo.c b/kernel/system/do_getinfo.c index fef7ce5a4..35213275c 100644 --- a/kernel/system/do_getinfo.c +++ b/kernel/system/do_getinfo.c @@ -43,7 +43,7 @@ int do_getinfo(struct proc * caller, message * m_ptr) /* Request system information to be copied to caller's address space. This * call simply copies entire data structures to the caller. */ - size_t length; + int length; vir_bytes src_vir; int nr_e, nr, r; int wipe_rnd_bin = -1; diff --git a/kernel/system/do_irqctl.c b/kernel/system/do_irqctl.c index 026fbfd6d..21b2b6306 100644 --- a/kernel/system/do_irqctl.c +++ b/kernel/system/do_irqctl.c @@ -26,7 +26,7 @@ int do_irqctl(struct proc * caller, message * m_ptr) /* Dismember the request message. */ int irq_vec; int irq_hook_id; - int notify_id; + unsigned int notify_id; int r = OK; int i; irq_hook_t *hook_ptr; @@ -141,8 +141,7 @@ int do_irqctl(struct proc * caller, message * m_ptr) /*===========================================================================* * generic_handler * *===========================================================================*/ -static int generic_handler(hook) -irq_hook_t *hook; +static int generic_handler(irq_hook_t *hook) { /* This function handles hardware interrupt in a simple and generic way. All * interrupts are transformed into messages to a driver. The IRQ line will be diff --git a/kernel/system/do_privctl.c b/kernel/system/do_privctl.c index 9bc2366de..51d7b8e8e 100644 --- a/kernel/system/do_privctl.c +++ b/kernel/system/do_privctl.c @@ -35,7 +35,7 @@ int do_privctl(struct proc * caller, message * m_ptr) int i, r; struct io_range io_range; struct minix_mem_range mem_range; - struct priv priv; + struct priv privs; int irq; /* Check whether caller is allowed to make this call. Privileged proceses @@ -85,12 +85,12 @@ int do_privctl(struct proc * caller, message * m_ptr) { /* Copy privilege structure from caller */ if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR, - KERNEL, (vir_bytes) &priv, sizeof(priv))) != OK) + KERNEL, (vir_bytes) &privs, sizeof(privs))) != OK) return r; /* See if the caller wants to assign a static privilege id. */ - if(!(priv.s_flags & DYN_PRIV_ID)) { - priv_id = priv.s_id; + if(!(privs.s_flags & DYN_PRIV_ID)) { + priv_id = privs.s_id; } } @@ -109,7 +109,7 @@ int do_privctl(struct proc * caller, message * m_ptr) priv(rp)->s_id = priv_id; /* restore privilege id */ priv(rp)->s_proc_nr = proc_nr; /* reassociate process nr */ - for (i=0; i< NR_SYS_CHUNKS; i++) /* remove pending: */ + for (i=0; i< (int)(NR_SYS_CHUNKS); i++) /* remove pending: */ priv(rp)->s_notify_pending.chunk[i] = 0; /* - notifications */ priv(rp)->s_int_pending = 0; /* - interrupts */ (void) sigemptyset(&priv(rp)->s_sig_pending); /* - signals */ @@ -128,7 +128,7 @@ int do_privctl(struct proc * caller, message * m_ptr) } fill_sendto_mask(rp, &map); kcalls = DSRV_KC; /* allowed kernel calls */ - for(i = 0; i < SYS_CALL_MASK_SIZE; i++) { + for(i = 0; i < (int)(SYS_CALL_MASK_SIZE); i++) { priv(rp)->s_k_call_mask[i] = (kcalls == NO_C ? 0 : (~0)); } @@ -148,7 +148,7 @@ int do_privctl(struct proc * caller, message * m_ptr) /* Override defaults if the caller has supplied a privilege structure. */ if (m_ptr->CTL_ARG_PTR) { - if((r = update_priv(rp, &priv)) != OK) { + if((r = update_priv(rp, &privs)) != OK) { return r; } } @@ -298,11 +298,11 @@ int do_privctl(struct proc * caller, message * m_ptr) /* Copy privilege structure from caller */ if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR, - KERNEL, (vir_bytes) &priv, sizeof(priv))) != OK) + KERNEL, (vir_bytes) &privs, sizeof(privs))) != OK) return r; /* Override settings in existing privilege structure. */ - if((r = update_priv(rp, &priv)) != OK) { + if((r = update_priv(rp, &privs)) != OK) { return r; } @@ -317,25 +317,25 @@ int do_privctl(struct proc * caller, message * m_ptr) /*===========================================================================* * update_priv * *===========================================================================*/ -static int update_priv(struct proc *rp, struct priv *priv) +static int update_priv(struct proc *rp, struct priv *privs) { /* Update the privilege structure of a given process. */ int i; /* Copy s_flags and signal managers. */ - priv(rp)->s_flags = priv->s_flags; - priv(rp)->s_sig_mgr = priv->s_sig_mgr; - priv(rp)->s_bak_sig_mgr = priv->s_bak_sig_mgr; + priv(rp)->s_flags = privs->s_flags; + priv(rp)->s_sig_mgr = privs->s_sig_mgr; + priv(rp)->s_bak_sig_mgr = privs->s_bak_sig_mgr; /* Copy IRQs. */ - if(priv->s_flags & CHECK_IRQ) { - if (priv->s_nr_irq < 0 || priv->s_nr_irq > NR_IRQ) + if(privs->s_flags & CHECK_IRQ) { + if (privs->s_nr_irq < 0 || privs->s_nr_irq > NR_IRQ) return EINVAL; - priv(rp)->s_nr_irq= priv->s_nr_irq; - for (i= 0; is_nr_irq; i++) + priv(rp)->s_nr_irq= privs->s_nr_irq; + for (i= 0; is_nr_irq; i++) { - priv(rp)->s_irq_tab[i]= priv->s_irq_tab[i]; + priv(rp)->s_irq_tab[i]= privs->s_irq_tab[i]; #if PRIV_DEBUG printf("do_privctl: adding IRQ %d for %d\n", priv(rp)->s_irq_tab[i], rp->p_endpoint); @@ -344,13 +344,13 @@ static int update_priv(struct proc *rp, struct priv *priv) } /* Copy I/O ranges. */ - if(priv->s_flags & CHECK_IO_PORT) { - if (priv->s_nr_io_range < 0 || priv->s_nr_io_range > NR_IO_RANGE) + if(privs->s_flags & CHECK_IO_PORT) { + if (privs->s_nr_io_range < 0 || privs->s_nr_io_range > NR_IO_RANGE) return EINVAL; - priv(rp)->s_nr_io_range= priv->s_nr_io_range; - for (i= 0; is_nr_io_range; i++) + priv(rp)->s_nr_io_range= privs->s_nr_io_range; + for (i= 0; is_nr_io_range; i++) { - priv(rp)->s_io_tab[i]= priv->s_io_tab[i]; + priv(rp)->s_io_tab[i]= privs->s_io_tab[i]; #if PRIV_DEBUG printf("do_privctl: adding I/O range [%x..%x] for %d\n", priv(rp)->s_io_tab[i].ior_base, @@ -361,13 +361,13 @@ static int update_priv(struct proc *rp, struct priv *priv) } /* Copy memory ranges. */ - if(priv->s_flags & CHECK_MEM) { - if (priv->s_nr_mem_range < 0 || priv->s_nr_mem_range > NR_MEM_RANGE) + if(privs->s_flags & CHECK_MEM) { + if (privs->s_nr_mem_range < 0 || privs->s_nr_mem_range > NR_MEM_RANGE) return EINVAL; - priv(rp)->s_nr_mem_range= priv->s_nr_mem_range; - for (i= 0; is_nr_mem_range; i++) + priv(rp)->s_nr_mem_range= privs->s_nr_mem_range; + for (i= 0; is_nr_mem_range; i++) { - priv(rp)->s_mem_tab[i]= priv->s_mem_tab[i]; + priv(rp)->s_mem_tab[i]= privs->s_mem_tab[i]; #if PRIV_DEBUG printf("do_privctl: adding mem range [%x..%x] for %d\n", priv(rp)->s_mem_tab[i].mr_base, @@ -378,18 +378,18 @@ static int update_priv(struct proc *rp, struct priv *priv) } /* Copy trap mask. */ - priv(rp)->s_trap_mask = priv->s_trap_mask; + priv(rp)->s_trap_mask = privs->s_trap_mask; /* Copy target mask. */ #if PRIV_DEBUG printf("do_privctl: Setting ipc target mask for %d:"); for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) { - printf(" %08x", get_sys_bits(priv->s_ipc_to, i)); + printf(" %08x", get_sys_bits(privs->s_ipc_to, i)); } printf("\n"); #endif - fill_sendto_mask(rp, &priv->s_ipc_to); + fill_sendto_mask(rp, &privs->s_ipc_to); #if PRIV_DEBUG printf("do_privctl: Set ipc target mask for %d:"); @@ -400,7 +400,7 @@ static int update_priv(struct proc *rp, struct priv *priv) #endif /* Copy kernel call mask. */ - memcpy(priv(rp)->s_k_call_mask, priv->s_k_call_mask, + memcpy(priv(rp)->s_k_call_mask, privs->s_k_call_mask, sizeof(priv(rp)->s_k_call_mask)); return OK; diff --git a/kernel/system/do_safecopy.c b/kernel/system/do_safecopy.c index 80d38fcb3..dffb18cd0 100644 --- a/kernel/system/do_safecopy.c +++ b/kernel/system/do_safecopy.c @@ -31,15 +31,10 @@ static int safecopy(struct proc *, endpoint_t, endpoint_t, /*===========================================================================* * verify_grant * *===========================================================================*/ -int verify_grant(granter, grantee, grant, bytes, access, - offset_in, offset_result, e_granter) -endpoint_t granter, grantee; /* copyee, copyer */ -cp_grant_id_t grant; /* grant id */ -vir_bytes bytes; /* copy size */ -int access; /* direction (read/write) */ -vir_bytes offset_in; /* copy offset within grant */ -vir_bytes *offset_result; /* copy offset within virtual address space */ -endpoint_t *e_granter; /* new granter (magic grants) */ +int verify_grant(endpoint_t granter, endpoint_t grantee, + cp_grant_id_t grant, vir_bytes bytes, + int access, vir_bytes offset_in, + vir_bytes *offset_result, endpoint_t *e_granter) { static cp_grant_t g; static int proc_nr; @@ -225,16 +220,9 @@ endpoint_t *e_granter; /* new granter (magic grants) */ /*===========================================================================* * safecopy * *===========================================================================*/ -static int safecopy(caller, granter, grantee, grantid, bytes, - g_offset, addr, access) -struct proc * caller; -endpoint_t granter, grantee; -cp_grant_id_t grantid; -size_t bytes; -vir_bytes g_offset, addr; -int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE - * for a copy from grantee to granter. - */ +static int safecopy(struct proc * caller, endpoint_t granter, + endpoint_t grantee, cp_grant_id_t grantid, size_t bytes, + vir_bytes g_offset, vir_bytes addr, int access) { static struct vir_addr v_src, v_dst; static vir_bytes v_offset; diff --git a/kernel/system/do_sigsend.c b/kernel/system/do_sigsend.c index 6c6e9babe..34b9ddae6 100644 --- a/kernel/system/do_sigsend.c +++ b/kernel/system/do_sigsend.c @@ -71,7 +71,7 @@ int do_sigsend(struct proc * caller, message * m_ptr) /* Initialize the sigframe structure. */ frp = (struct sigframe *) scp - 1; fr.sf_scpcopy = scp; - fr.sf_retadr2= (void (*)()) rp->p_reg.pc; + fr.sf_retadr2= (void (*)(void)) rp->p_reg.pc; fr.sf_fp = rp->p_reg.fp; rp->p_reg.fp = (reg_t) &frp->sf_fp; fr.sf_scp = scp; @@ -79,7 +79,7 @@ int do_sigsend(struct proc * caller, message * m_ptr) fpu_sigcontext(rp, &fr, &sc); fr.sf_signo = smsg.sm_signo; - fr.sf_retadr = (void (*)()) smsg.sm_sigreturn; + fr.sf_retadr = (void (*)(void)) smsg.sm_sigreturn; #if defined(__arm__) /* use the ARM link register to set the return address from the signal diff --git a/kernel/system/do_sysctl.c b/kernel/system/do_sysctl.c index 5bc6b100a..f162642ce 100644 --- a/kernel/system/do_sysctl.c +++ b/kernel/system/do_sysctl.c @@ -16,7 +16,8 @@ int do_sysctl(struct proc * caller, message * m_ptr) { vir_bytes len, buf; static char mybuf[DIAG_BUFSIZE]; - int s, i, proc_nr; + int s, proc_nr; + unsigned int i; switch (m_ptr->SYSCTL_CODE) { case SYSCTL_CODE_DIAG: diff --git a/kernel/system/do_umap_remote.c b/kernel/system/do_umap_remote.c index 9d0b4065e..84bb37cde 100644 --- a/kernel/system/do_umap_remote.c +++ b/kernel/system/do_umap_remote.c @@ -29,7 +29,7 @@ int do_umap_remote(struct proc * caller, message * m_ptr) int seg_type = m_ptr->UMAP_SEG & SEGMENT_TYPE; int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX; vir_bytes offset = m_ptr->CP_SRC_ADDR; - int count = m_ptr->CP_NR_BYTES; + size_t count = m_ptr->CP_NR_BYTES; int endpt = (int) m_ptr->CP_SRC_ENDPT; endpoint_t grantee = (endpoint_t) m_ptr->CP_DST_ENDPT; int proc_nr, proc_nr_grantee; diff --git a/kernel/system/do_vdevio.c b/kernel/system/do_vdevio.c index 8292e1295..11dad33b9 100644 --- a/kernel/system/do_vdevio.c +++ b/kernel/system/do_vdevio.c @@ -31,11 +31,11 @@ int do_vdevio(struct proc * caller, message * m_ptr) * that I/O batch from being interrrupted. * This is the counterpart of do_devio, which performs a single device I/O. */ - int vec_size; /* size of vector */ + unsigned int vec_size; /* size of vector */ int io_in; /* true if input */ size_t bytes; /* # bytes to be copied */ port_t port; - int i, j, io_size, nr_io_range; + unsigned int i, j, io_size, nr_io_range; int io_dir, io_type; struct priv *privp; struct io_range *iorp; diff --git a/kernel/system/do_vtimer.c b/kernel/system/do_vtimer.c index 790054bc9..089e1d0ae 100644 --- a/kernel/system/do_vtimer.c +++ b/kernel/system/do_vtimer.c @@ -80,8 +80,7 @@ int do_vtimer(struct proc * caller, message * m_ptr) /*===========================================================================* * vtimer_check * *===========================================================================*/ -void vtimer_check(rp) -struct proc *rp; /* pointer to the process */ +void vtimer_check(struct proc *rp) { /* This is called from the clock task, so we can be interrupted by the clock * interrupt, but not by the system task. Therefore we only have to protect diff --git a/kernel/table.c b/kernel/table.c index e77dc2013..b57f1e95e 100644 --- a/kernel/table.c +++ b/kernel/table.c @@ -44,24 +44,24 @@ struct boot_image image[NR_BOOT_PROCS] = { /* process nr, flags, stack size, name */ -{ASYNCM, "asyncm"}, -{IDLE, "idle" }, -{CLOCK, "clock" }, -{SYSTEM, "system"}, -{HARDWARE, "kernel"}, +{ASYNCM, "asyncm", 0, 0, 0}, +{IDLE, "idle" , 0, 0, 0}, +{CLOCK, "clock" , 0, 0, 0}, +{SYSTEM, "system", 0, 0, 0}, +{HARDWARE, "kernel", 0, 0, 0}, -{DS_PROC_NR, "ds" }, -{RS_PROC_NR, "rs" }, +{DS_PROC_NR, "ds" , 0, 0, 0}, +{RS_PROC_NR, "rs" , 0, 0, 0}, -{PM_PROC_NR, "pm" }, -{SCHED_PROC_NR, "sched" }, -{VFS_PROC_NR, "vfs" }, -{MEM_PROC_NR, "memory"}, -{LOG_PROC_NR, "log" }, -{TTY_PROC_NR, "tty" }, -{MFS_PROC_NR, "mfs" }, -{VM_PROC_NR, "vm" }, -{PFS_PROC_NR, "pfs" }, -{INIT_PROC_NR, "init" }, +{PM_PROC_NR, "pm" , 0, 0, 0}, +{SCHED_PROC_NR, "sched" , 0, 0, 0}, +{VFS_PROC_NR, "vfs" , 0, 0, 0}, +{MEM_PROC_NR, "memory", 0, 0, 0}, +{LOG_PROC_NR, "log" , 0, 0, 0}, +{TTY_PROC_NR, "tty" , 0, 0, 0}, +{MFS_PROC_NR, "mfs" , 0, 0, 0}, +{VM_PROC_NR, "vm" , 0, 0, 0}, +{PFS_PROC_NR, "pfs" , 0, 0, 0}, +{INIT_PROC_NR, "init" , 0, 0, 0}, }; diff --git a/kernel/utility.c b/kernel/utility.c index f112ee07a..4fab99eb6 100644 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -14,7 +14,7 @@ #include -#define ARE_PANICING 0xDEADC0FF +#define ARE_PANICING (int) 0x0DEADC0F /*===========================================================================* * panic * @@ -51,8 +51,7 @@ void panic(const char *fmt, ...) /*===========================================================================* * kputc * *===========================================================================*/ -void kputc(c) -int c; /* character to append */ +void kputc(int c) /* character to append */ { /* Accumulate a single character for a kernel message. Send a notification * to the output driver if an END_OF_KMESS is encountered. @@ -92,8 +91,7 @@ int c; /* character to append */ /*===========================================================================* * _exit * *===========================================================================*/ -void _exit(e) -int e; /* error code */ +void _exit(int e) { panic("_exit called from within the kernel, should not happen. (err %i)", e); } diff --git a/lib/libsys/assert.c b/lib/libsys/assert.c index e70f4c5ec..18ca97e72 100644 --- a/lib/libsys/assert.c +++ b/lib/libsys/assert.c @@ -10,9 +10,7 @@ #include void -__assert13(file, line, function, failedexpr) - const char *file, *function, *failedexpr; - int line; +__assert13(const char *file, int line, const char *function, const char *failedexpr) { (void)printf("%s:%d: assert \"%s\" failed", file, line, failedexpr); if(function) printf(", function \"%s\"", function); @@ -22,9 +20,7 @@ __assert13(file, line, function, failedexpr) } void -__assert(file, line, failedexpr) - const char *file, *failedexpr; - int line; +__assert(const char *file, int line, const char *failedexpr) { __assert13(file, line, NULL, failedexpr); diff --git a/lib/libsys/stacktrace.c b/lib/libsys/stacktrace.c index 8185956a9..c1be9b3ea 100644 --- a/lib/libsys/stacktrace.c +++ b/lib/libsys/stacktrace.c @@ -6,6 +6,7 @@ Created: Jan 19, 1993 by Philip Homburg Copyright 1995 Philip Homburg */ +#include #include #include diff --git a/lib/libsys/vprintf.c b/lib/libsys/vprintf.c index 8c4163492..1bccd774f 100644 --- a/lib/libsys/vprintf.c +++ b/lib/libsys/vprintf.c @@ -10,7 +10,7 @@ void kputc(int c); #define count_kputc(c) do { charcount++; putf((c), farg); } while(0) -int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *farg) +static int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *farg) { int c, charcount = 0; enum { LEFT, RIGHT } adjust; @@ -19,8 +19,8 @@ int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *f int width, max, len, base; static char X2C_tab[]= "0123456789ABCDEF"; static char x2c_tab[]= "0123456789abcdef"; - char *x2c; - char *p; + char *x2c, *pp; + const char *p; long long i; unsigned long long u = 0; char temp[8 * sizeof(long long) / 3 + 2]; @@ -131,25 +131,27 @@ int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *f case INT: u= va_arg(argp, unsigned int); break; } int2ascii: - p= temp + sizeof(temp)-1; - *p= 0; + pp= temp + sizeof(temp)-1; + *pp= 0; do { - *--p= x2c[(ptrdiff_t) (u % base)]; + *--pp= x2c[(ptrdiff_t) (u % base)]; } while ((u /= base) > 0); + p = pp; goto string_length; /* A character. */ case 'c': - p= temp; - *p= va_arg(argp, int); + p = pp= temp; + *pp= va_arg(argp, int); len= 1; goto string_print; /* Simply a percent. */ case '%': - p= temp; - *p= '%'; + pp = temp; + *pp= '%'; len= 1; + p = pp; goto string_print; /* A string. The other cases will join in here. */ @@ -185,6 +187,9 @@ int __fvprintf(void (*putf)(int, void *), const char *fmt, va_list argp, void *f return charcount; } +#define vprintf _vprintf +#define vfprintf _vfprintf + #include #include #include @@ -211,12 +216,12 @@ __xfputc(int c, void *arg) kputc(c); } -int _vprintf(const char *fmt, va_list argp) +int vprintf(const char *fmt, va_list argp) { return __fvprintf(__xfputc, fmt, argp, stdout); } -int _vfprintf(FILE *fp, const char *fmt, va_list argp) +int vfprintf(FILE *fp, const char *fmt, va_list argp) { return __fvprintf(__xfputc, fmt, argp, fp); }