kernel: make WARNS=5 proof

Change-Id: Ic17d35bcb9ea05611d7ac23150bd36d510052735
This commit is contained in:
Ben Gras 2013-08-20 14:14:28 +00:00
parent 0c044c6b02
commit ded911e15f
39 changed files with 268 additions and 276 deletions

View File

@ -135,7 +135,7 @@ struct memory {
/* The kernel outputs diagnostic messages in a circular buffer. */ /* The kernel outputs diagnostic messages in a circular buffer. */
struct kmessages { struct kmessages {
int km_next; /* next index to write */ 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 km_buf[_KMESS_BUF_SIZE]; /* buffer for messages */
char kmess_buf[80*25]; /* printable copy of message buffer */ char kmess_buf[80*25]; /* printable copy of message buffer */
int blpos; /* kmess_buf position */ int blpos; /* kmess_buf position */

View File

@ -3,6 +3,8 @@
USE_BITCODE:=no USE_BITCODE:=no
WARNS=5
BINDIR= /usr/sbin BINDIR= /usr/sbin
MAN= MAN=
PROG= kernel PROG= kernel

View File

@ -43,7 +43,7 @@ static u16_t pm1b_cnt_blk = 0;
static u16_t slp_typa = 0; static u16_t slp_typa = 0;
static u16_t slp_typb = 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; u8_t total = 0;
int i; int i;
@ -120,7 +120,7 @@ static int acpi_read_sdt_at(phys_bytes addr,
return tb->length; return tb->length;
} }
phys_bytes acpi_get_table_base(const char * name) static phys_bytes acpi_get_table_base(const char * name)
{ {
int i; int i;
@ -133,7 +133,8 @@ phys_bytes acpi_get_table_base(const char * name)
return (phys_bytes) NULL; 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; int i;
@ -145,13 +146,14 @@ size_t acpi_get_table_length(const char * name)
return 0; return 0;
} }
#endif
static void * acpi_madt_get_typed_item(struct acpi_madt_hdr * hdr, static void * acpi_madt_get_typed_item(struct acpi_madt_hdr * hdr,
unsigned char type, unsigned char type,
unsigned idx) unsigned idx)
{ {
u8_t * t, * end; u8_t * t, * end;
int i; unsigned int i;
t = (u8_t *) hdr + sizeof(struct acpi_madt_hdr); t = (u8_t *) hdr + sizeof(struct acpi_madt_hdr);
end = (u8_t *) hdr + hdr->hdr.length; end = (u8_t *) hdr + hdr->hdr.length;
@ -235,7 +237,7 @@ static void acpi_init_poweroff(void)
u8_t *end = NULL; u8_t *end = NULL;
struct acpi_fadt_header *fadt_header = NULL; struct acpi_fadt_header *fadt_header = NULL;
struct acpi_rsdt * dsdt_header = NULL; struct acpi_rsdt * dsdt_header = NULL;
char *msg = NULL; const char *msg = NULL;
/* Everything used here existed since ACPI spec 1.0 */ /* Everything used here existed since ACPI spec 1.0 */
/* So we can safely use them */ /* So we can safely use them */
@ -394,11 +396,6 @@ struct acpi_madt_lapic * acpi_get_lapic_next(void)
return ret; return ret;
} }
void __k_unpaged_acpi_poweroff(void)
{
/* NO OP poweroff symbol*/
}
void acpi_poweroff(void) void acpi_poweroff(void)
{ {
if (pm1a_cnt_blk == 0) { if (pm1a_cnt_blk == 0) {

View File

@ -157,10 +157,12 @@ static u32_t lapic_tctr0, lapic_tctr1;
static unsigned apic_imcrp; static unsigned apic_imcrp;
static const unsigned nlints = 0; static const unsigned nlints = 0;
void arch_eoi(void) #if 0
static void arch_eoi(void)
{ {
apic_eoi(); apic_eoi();
} }
#endif
/* /*
* FIXME this should be a cpulocal variable but there are some problems with * 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 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) static void ioapic_enable_pin(vir_bytes ioapic_addr, int pin)
{ {
@ -297,10 +299,12 @@ void ioapic_eoi(int irq)
irq_8259_eoi(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); ioapic_write(addr, IOAPIC_ID, id << 24);
} }
#endif
int ioapic_enable_all(void) int ioapic_enable_all(void)
{ {
@ -405,7 +409,7 @@ void ioapic_mask_irq(unsigned irq)
irq_8259_mask(irq); irq_8259_mask(irq);
} }
unsigned int apicid(void) static int apicid(void)
{ {
return lapic_read(LAPIC_ID) >> 24; return lapic_read(LAPIC_ID) >> 24;
} }
@ -868,7 +872,7 @@ static void lapic_set_dummy_handlers(void)
#endif #endif
/* Build descriptors for interrupt gates in IDT. */ /* Build descriptors for interrupt gates in IDT. */
void apic_idt_init(const int reset) void apic_idt_init(const int resetv)
{ {
u32_t val; u32_t val;
@ -876,7 +880,7 @@ void apic_idt_init(const int reset)
*/ */
int is_bsp; int is_bsp;
if (reset) { if (resetv) {
idt_copy_vectors_pic(); idt_copy_vectors_pic();
idt_copy_vectors(gate_table_common); idt_copy_vectors(gate_table_common);
return; return;
@ -1173,7 +1177,7 @@ static eoi_method_t set_eoi_method(unsigned irq)
return ioapic_eoi_level; 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; u32_t val = 0;

View File

@ -376,10 +376,10 @@ short cpu_load(void)
void busy_delay_ms(int ms) void busy_delay_ms(int ms)
{ {
u64_t cycles = ms_2_cpu_time(ms), tsc0, tsc, tsc1; u64_t cycles = ms_2_cpu_time(ms), ctsc0, ctsc, ctsc1;
read_tsc_64(&tsc0); read_tsc_64(&ctsc0);
tsc1 = tsc0 + cycles; ctsc1 = ctsc0 + cycles;
do { read_tsc_64(&tsc); } while(tsc < tsc1); do { read_tsc_64(&ctsc); } while(ctsc < ctsc1);
return; return;
} }

View File

@ -36,9 +36,8 @@ static void setcr3(struct proc *p, u32_t cr3, u32_t *v)
/*===========================================================================* /*===========================================================================*
* arch_do_vmctl * * arch_do_vmctl *
*===========================================================================*/ *===========================================================================*/
int arch_do_vmctl(m_ptr, p) int arch_do_vmctl(register message *m_ptr, /* pointer to request message */
register message *m_ptr; /* pointer to request message */ struct proc *p)
struct proc *p;
{ {
switch(m_ptr->SVMCTL_PARAM) { switch(m_ptr->SVMCTL_PARAM) {
case VMCTL_GET_PDBR: case VMCTL_GET_PDBR:

View File

@ -286,7 +286,7 @@ void arch_init(void)
/*===========================================================================* /*===========================================================================*
* do_ser_debug * * do_ser_debug *
*===========================================================================*/ *===========================================================================*/
void do_ser_debug() void do_ser_debug(void)
{ {
u8_t c, lsr; u8_t c, lsr;
@ -421,7 +421,7 @@ static void ser_debug(const int c)
#if DEBUG_SERIAL #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 /* Notify VFS it has to generate stack traces. Kernel can't do that as
* it's not aware of user space threads. * it's not aware of user space threads.
@ -487,14 +487,15 @@ void arch_ack_profile_clock(void)
#endif #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 */ /* 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. */ /* Make the system call, for real this time. */
assert(proc->p_misc_flags & MF_SC_DEFER); assert(whichproc->p_misc_flags & MF_SC_DEFER);
proc->p_reg.retreg = whichproc->p_reg.retreg =
do_ipc(proc->p_defer.r1, proc->p_defer.r2, proc->p_defer.r3); do_ipc(whichproc->p_defer.r1, whichproc->p_defer.r2,
whichproc->p_defer.r3);
} }
struct proc * arch_finish_switch_to_user(void) 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; 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; int trap_style = p->p_seg.p_kern_trap_style;
#if 0 #if 0

View File

@ -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" printf("KERNEL LOCK UP\n"
"eax 0x%08x\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 = { static struct arch_watchdog intel_arch_watchdog = {
/*.init = */ intel_arch_watchdog_init, .init = intel_arch_watchdog_init,
/*.reinit = */ intel_arch_watchdog_reinit, .reinit = intel_arch_watchdog_reinit,
/*.profile_init = */ intel_arch_watchdog_profile_init .profile_init = intel_arch_watchdog_profile_init,
.resetval = 0
}; };
#define AMD_MSR_EVENT_SEL0 0xc0010000 #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 = { static struct arch_watchdog amd_watchdog = {
/*.init = */ amd_watchdog_init, .init = amd_watchdog_init,
/*.reinit = */ amd_watchdog_reinit, .reinit = amd_watchdog_reinit,
/*.profile_init = */ amd_watchdog_profile_init .profile_init = amd_watchdog_profile_init,
.resetval = 0
}; };

View File

@ -24,7 +24,7 @@ extern char *video_mem;
#define VIDOFFSET(line, col) ((line) * MULTIBOOT_CONSOLE_COLS * 2 + (col) * 2) #define VIDOFFSET(line, col) ((line) * MULTIBOOT_CONSOLE_COLS * 2 + (col) * 2)
#define VIDSIZE VIDOFFSET(MULTIBOOT_CONSOLE_LINES-1,MULTIBOOT_CONSOLE_COLS-1) #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); int offset = VIDOFFSET(line, col);
video_mem[offset] = c; video_mem[offset] = c;

View File

@ -17,6 +17,7 @@ int do_readbios(struct proc * caller, message * m_ptr)
{ {
struct vir_addr src, dst; struct vir_addr src, dst;
vir_bytes len = m_ptr->RDB_SIZE, limit; vir_bytes len = m_ptr->RDB_SIZE, limit;
phys_bytes biosbegin = BIOS_MEM_BEGIN;
src.offset = m_ptr->RDB_ADDR; src.offset = m_ptr->RDB_ADDR;
dst.offset = (vir_bytes) m_ptr->RDB_BUF; 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 SUBRANGE(a,b,c,d) (VINRANGE((a), (c), (d)) && VINRANGE((b),(c),(d)))
#define USERRANGE(a, b) SUBRANGE(src.offset, limit, (a), (b)) #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)) !USERRANGE(BASE_MEM_TOP, UPPER_MEM_END))
return EPERM; return EPERM;

View File

@ -28,9 +28,10 @@ int do_sdevio(struct proc * caller, message *m_ptr)
int proc_nr; int proc_nr;
endpoint_t proc_nr_e = m_ptr->DIO_VEC_ENDPT; endpoint_t proc_nr_e = m_ptr->DIO_VEC_ENDPT;
vir_bytes count = m_ptr->DIO_VEC_SIZE; 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; 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 priv *privp;
struct io_range *iorp; struct io_range *iorp;
struct proc *destproc; struct proc *destproc;

View File

@ -11,7 +11,7 @@
#include <machine/vm.h> #include <machine/vm.h>
struct ex_s { struct ex_s {
char *msg; const char *msg;
int signum; int signum;
int minprocessor; int minprocessor;
}; };
@ -129,7 +129,7 @@ static void pagefault( struct proc *pr,
return; 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, struct exception_frame * frame, struct ex_s *ep,
int is_nested) int is_nested)
{ {

View File

@ -80,6 +80,7 @@ struct exception_frame {
}; };
void exception(struct exception_frame * frame); void exception(struct exception_frame * frame);
void exception_handler(int is_nested, struct exception_frame * frame);
/* klib.S */ /* klib.S */
__dead void monitor(void); __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 ((* increment, void * buff, unsigned size, phys_bytes * phys_addr, int ((*
cmp_f)(void *))); cmp_f)(void *)));
/* pre_init.c */
kinfo_t *pre_init(u32_t magic, u32_t ebx);
/* breakpoints.c */ /* breakpoints.c */
int breakpoint_set(phys_bytes linaddr, int bp, const int flags); int breakpoint_set(phys_bytes linaddr, int bp, const int flags);
#define BREAKPOINT_COUNT 4 #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_LOCAL (1 << 4)
#define BREAKPOINT_FLAG_MODE_GLOBAL (2 << 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. */ /* functions defined in architecture-independent kernel source. */
#include "kernel/proto.h" #include "kernel/proto.h"

View File

@ -276,11 +276,10 @@ static char *cr4_str(u32_t e)
/*===========================================================================* /*===========================================================================*
* umap_virtual * * umap_virtual *
*===========================================================================*/ *===========================================================================*/
phys_bytes umap_virtual(rp, seg, vir_addr, bytes) phys_bytes umap_virtual(register struct proc *rp, /* pointer to process */
register struct proc *rp; /* pointer to proc table entry for process */ int seg, /* T, D, or S segment */
int seg; /* T, D, or S segment */ vir_bytes vir_addr, /* virtual address in bytes within the seg */
vir_bytes vir_addr; /* virtual address in bytes within the seg */ vir_bytes bytes) /* # of bytes to be copied */
vir_bytes bytes; /* # of bytes to be copied */
{ {
phys_bytes phys = 0; phys_bytes phys = 0;
@ -318,20 +317,20 @@ vir_bytes bytes; /* # of bytes to be copied */
/*===========================================================================* /*===========================================================================*
* vm_lookup * * 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) phys_bytes *physical, u32_t *ptent)
{ {
u32_t *root, *pt; u32_t *root, *pt;
int pde, pte; int pde, pte;
u32_t pde_v, pte_v; u32_t pde_v, pte_v;
assert(proc); assert(whichproc);
assert(physical); assert(physical);
assert(!isemptyp(proc)); assert(!isemptyp(whichproc));
assert(HASPT(proc)); assert(HASPT(whichproc));
/* Retrieve page directory entry. */ /* 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)); assert(!((u32_t) root % I386_PAGE_SIZE));
pde = I386_VM_PDE(virtual); pde = I386_VM_PDE(virtual);
assert(pde >= 0 && pde < I386_VM_DIR_ENTRIES); 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 * * 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) phys_bytes *phys_addr, size_t bytes)
{ {
/* Look up the physical address corresponding to linear virtual address /* 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; phys_bytes phys, next_phys;
size_t len; size_t len;
assert(proc); assert(whichproc);
assert(bytes > 0); assert(bytes > 0);
assert(HASPT(proc)); assert(HASPT(proc));
/* Look up the first page. */ /* 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; return 0;
if (phys_addr != NULL) 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. */ /* Look up any next pages and test physical contiguity. */
while (len < bytes) { while (len < bytes) {
if (vm_lookup(proc, vir_addr, &phys, NULL) != OK) if (vm_lookup(whichproc, vir_addr, &phys, NULL) != OK)
break; break;
if (next_phys != phys) 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 * * virtual_copy_f *
*===========================================================================*/ *===========================================================================*/
int virtual_copy_f(caller, src_addr, dst_addr, bytes, vmcheck) int virtual_copy_f(struct proc * caller,
struct proc * caller; struct vir_addr *src_addr, /* source virtual address */
struct vir_addr *src_addr; /* source virtual address */ struct vir_addr *dst_addr, /* destination virtual address */
struct vir_addr *dst_addr; /* destination virtual address */ vir_bytes bytes, /* # of bytes to copy */
vir_bytes bytes; /* # of bytes to copy */ int vmcheck) /* if nonzero, can return VMSUSPEND */
int vmcheck; /* if nonzero, can return VMSUSPEND */
{ {
/* Copy bytes from virtual address src_addr to virtual address dst_addr. */ /* Copy bytes from virtual address src_addr to virtual address dst_addr. */
struct vir_addr *vir_addr[2]; /* virtual source and destination address */ 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; 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 *addr,
phys_bytes *len, phys_bytes *len,
int *flags) int *flags)
{ {
static int first = 1; static int first = 1;
int freeidx = 0; 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 glo_len = (u32_t) &usermapped_nonglo_start -
(u32_t) &usermapped_start; (u32_t) &usermapped_start;
@ -840,20 +838,20 @@ int arch_phys_map(const int index,
first = 0; first = 0;
} }
if(index == usermapped_glo_index) { if(mindex == usermapped_glo_index) {
*addr = vir2phys(&usermapped_start); *addr = vir2phys(&usermapped_start);
*len = glo_len; *len = glo_len;
*flags = VMMF_USER | VMMF_GLO; *flags = VMMF_USER | VMMF_GLO;
return OK; return OK;
} }
else if(index == usermapped_index) { else if(mindex == usermapped_index) {
*addr = vir2phys(&usermapped_nonglo_start); *addr = vir2phys(&usermapped_nonglo_start);
*len = (u32_t) &usermapped_end - *len = (u32_t) &usermapped_end -
(u32_t) &usermapped_nonglo_start; (u32_t) &usermapped_nonglo_start;
*flags = VMMF_USER; *flags = VMMF_USER;
return OK; 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 */ /* map video memory in so we can print panic messages */
*addr = MULTIBOOT_VIDEO_BUFFER; *addr = MULTIBOOT_VIDEO_BUFFER;
*len = I386_PAGE_SIZE; *len = I386_PAGE_SIZE;
@ -861,7 +859,7 @@ int arch_phys_map(const int index,
return OK; return OK;
} }
#ifdef USE_APIC #ifdef USE_APIC
else if (index == lapic_mapping_index) { else if (mindex == lapic_mapping_index) {
/* map the local APIC if enabled */ /* map the local APIC if enabled */
if (!lapic_addr) if (!lapic_addr)
return EINVAL; return EINVAL;
@ -870,8 +868,8 @@ int arch_phys_map(const int index,
*flags = VMMF_UNCACHED | VMMF_WRITE; *flags = VMMF_UNCACHED | VMMF_WRITE;
return OK; return OK;
} }
else if (ioapic_enabled && index >= ioapic_first_index && index <= ioapic_last_index) { else if (ioapic_enabled && mindex >= ioapic_first_index && mindex <= ioapic_last_index) {
int ioapic_idx = index - ioapic_first_index; int ioapic_idx = mindex - ioapic_first_index;
*addr = io_apic[ioapic_idx].paddr; *addr = io_apic[ioapic_idx].paddr;
assert(*addr); assert(*addr);
*len = 4 << 10 /* 4kB */; *len = 4 << 10 /* 4kB */;
@ -882,7 +880,7 @@ int arch_phys_map(const int index,
#endif #endif
#if CONFIG_OXPCIE #if CONFIG_OXPCIE
if(index == oxpcie_mapping_index) { if(mindex == oxpcie_mapping_index) {
*addr = strtoul(ser_var+2, NULL, 16); *addr = strtoul(ser_var+2, NULL, 16);
*len = 0x4000; *len = 0x4000;
*flags = VMMF_UNCACHED | VMMF_WRITE; *flags = VMMF_UNCACHED | VMMF_WRITE;
@ -893,29 +891,29 @@ int arch_phys_map(const int index,
return EINVAL; 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 #ifdef USE_APIC
/* if local APIC is enabled */ /* if local APIC is enabled */
if (index == lapic_mapping_index && lapic_addr) { if (mindex == lapic_mapping_index && lapic_addr) {
lapic_addr_vaddr = addr; lapic_addr_vaddr = addr;
return OK; return OK;
} }
else if (ioapic_enabled && index >= ioapic_first_index && else if (ioapic_enabled && mindex >= ioapic_first_index &&
index <= ioapic_last_index) { mindex <= ioapic_last_index) {
int i = index - ioapic_first_index; int i = mindex - ioapic_first_index;
io_apic[i].vaddr = addr; io_apic[i].vaddr = addr;
return OK; return OK;
} }
#endif #endif
#if CONFIG_OXPCIE #if CONFIG_OXPCIE
if (index == oxpcie_mapping_index) { if (mindex == oxpcie_mapping_index) {
oxpcie_set_vaddr((unsigned char *) addr); oxpcie_set_vaddr((unsigned char *) addr);
return OK; return OK;
} }
#endif #endif
if(index == first_um_idx) { if(mindex == first_um_idx) {
extern struct minix_ipcvecs minix_ipcvecs_sysenter, extern struct minix_ipcvecs minix_ipcvecs_sysenter,
minix_ipcvecs_syscall, minix_ipcvecs_syscall,
minix_ipcvecs_softint; minix_ipcvecs_softint;
@ -971,9 +969,9 @@ int arch_phys_map_reply(const int index, const vir_bytes addr)
return OK; 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; video_mem_vaddr = addr;
return OK; return OK;
} }
@ -1000,7 +998,7 @@ int arch_enable_paging(struct proc * caller)
} }
/* if IO apics are enabled */ /* if IO apics are enabled */
if (ioapic_enabled) { if (ioapic_enabled) {
int i; unsigned int i;
for (i = 0; i < nioapics; i++) { for (i = 0; i < nioapics; i++) {
io_apic[i].addr = io_apic[i].vaddr; io_apic[i].addr = io_apic[i].vaddr;

View File

@ -18,7 +18,8 @@ static phys_bytes kern_kernlen = (phys_bytes) &_kern_size;
/* page directory we can use to map things */ /* page directory we can use to map things */
static u32_t pagedir[1024] __aligned(4096); static u32_t pagedir[1024] __aligned(4096);
void print_memmap(kinfo_t *cbi) #if 0
static void print_memmap(kinfo_t *cbi)
{ {
int m; int m;
assert(cbi->mmap_size < MAXMEMMAP); assert(cbi->mmap_size < MAXMEMMAP);
@ -28,6 +29,7 @@ void print_memmap(kinfo_t *cbi)
} }
printf("\nsize %08lx\n", cbi->mmap_size); printf("\nsize %08lx\n", cbi->mmap_size);
} }
#endif
void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end) 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"); panic("no available memmap slot");
} }
u32_t *alloc_pagetable(phys_bytes *ph) static u32_t *alloc_pagetable(phys_bytes *ph)
{ {
u32_t *ret; u32_t *ret;
#define PG_PAGETABLES 6 #define PG_PAGETABLES 6
@ -135,7 +137,7 @@ u32_t *alloc_pagetable(phys_bytes *ph)
#define PAGE_KB (I386_PAGE_SIZE / 1024) #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; int m;
multiboot_memory_map_t *mmap; multiboot_memory_map_t *mmap;
@ -239,7 +241,7 @@ void vm_enable_paging(void)
write_cr4(cr4); write_cr4(cr4);
} }
phys_bytes pg_load() phys_bytes pg_load(void)
{ {
phys_bytes phpagedir = vir2phys(pagedir); phys_bytes phpagedir = vir2phys(pagedir);
write_cr3(phpagedir); write_cr3(phpagedir);
@ -251,7 +253,7 @@ void pg_clear(void)
memset(pagedir, 0, sizeof(pagedir)); memset(pagedir, 0, sizeof(pagedir));
} }
phys_bytes pg_rounddown(phys_bytes b) static phys_bytes pg_rounddown(phys_bytes b)
{ {
phys_bytes o; phys_bytes o;
if(!(o = b % I386_PAGE_SIZE)) if(!(o = b % I386_PAGE_SIZE))

View File

@ -1,8 +1,10 @@
#define UNPAGED 1 /* for proper kmain() prototype */ #define UNPAGED 1 /* for proper kmain() prototype */
#include "acpi.h"
#include "kernel/kernel.h" #include "kernel/kernel.h"
#include <assert.h> #include <assert.h>
#include <signal.h>
#include <stdlib.h> #include <stdlib.h>
#include <minix/minlib.h> #include <minix/minlib.h>
#include <minix/const.h> #include <minix/const.h>
@ -39,7 +41,7 @@ char *video_mem = (char *) MULTIBOOT_VIDEO_BUFFER;
/* Kernel may use memory */ /* Kernel may use memory */
int kernel_may_alloc = 1; 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 *p = bigbuf;
char *bufend = bigbuf + MULTIBOOT_PARAM_BUF_SIZE; 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; 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]; multiboot_module_t *cmp = &mod[cmp_mod];
int m; int m;
@ -98,7 +100,7 @@ int overlaps(multiboot_module_t *mod, int n, int cmp_mod)
return 0; 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_memory_map_t *mmap;
multiboot_info_t *mbi = &cbi->mbi; 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 minix_shutdown(timer_t *t) { arch_shutdown(RBT_PANIC); }
void busy_delay_ms(int x) { } void busy_delay_ms(int x) { }
int raise(int sig) { panic("raise(%d)\n", sig); } int raise(int sig) { panic("raise(%d)\n", sig); }
__dead void acpi_poweroff(void) { while(1) ; }

View File

@ -55,7 +55,7 @@ void enable_iop(struct proc *pp)
/*===========================================================================* /*===========================================================================*
* sdesc * * 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. */ /* Fill in the size fields (base, limit and granularity) of a descriptor. */
segdp->base_low = base; segdp->base_low = base;
@ -77,7 +77,7 @@ void enable_iop(struct proc *pp)
/*===========================================================================* /*===========================================================================*
* init_dataseg * * 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) phys_bytes base, vir_bytes size, const int privilege)
{ {
/* Build descriptor for a data segment. */ /* 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 */ /* 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 * * init_codeseg *
*===========================================================================*/ *===========================================================================*/
static void init_codeseg(int index, int privilege) static void init_codeseg(int cindex, int privilege)
{ {
/* Build descriptor for a code segment. */ /* Build descriptor for a code segment. */
sdesc(&gdt[index], 0, 0xFFFFFFFF); sdesc(&gdt[cindex], 0, 0xFFFFFFFF);
gdt[index].access = (privilege << DPL_SHIFT) gdt[cindex].access = (privilege << DPL_SHIFT)
| (PRESENT | SEGMENT | EXECUTABLE | READABLE); | (PRESENT | SEGMENT | EXECUTABLE | READABLE);
/* CONFORMING = 0, ACCESSED = 0 */ /* CONFORMING = 0, ACCESSED = 0 */
} }
@ -154,10 +154,10 @@ static struct gate_table_s gate_table_exceptions[] = {
int tss_init(unsigned cpu, void * kernel_stack) int tss_init(unsigned cpu, void * kernel_stack)
{ {
struct tss_s * t = &tss[cpu]; struct tss_s * t = &tss[cpu];
int index = TSS_INDEX(cpu); int tindex = TSS_INDEX(cpu);
struct segdesc_s *tssgdt; struct segdesc_s *tssgdt;
tssgdt = &gdt[index]; tssgdt = &gdt[tindex];
init_param_dataseg(tssgdt, (phys_bytes) t, init_param_dataseg(tssgdt, (phys_bytes) t,
sizeof(struct tss_s), INTR_PRIVILEGE); sizeof(struct tss_s), INTR_PRIVILEGE);
@ -212,10 +212,11 @@ int tss_init(unsigned cpu, void * kernel_stack)
assert(CONFIG_MAX_CPUS <= 8); 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]; struct desctableptr_s *dtp = (struct desctableptr_s *) &gdt[gdt_index];
dtp->limit = size - 1; dtp->limit = size - 1;
@ -223,8 +224,9 @@ phys_bytes init_segdesc(int gdt_index, void *base, int size)
return (phys_bytes) dtp; 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) unsigned vec_nr, vir_bytes offset, unsigned dpl_type)
{ {
/* Build descriptor for an interrupt gate. */ /* Build descriptor for an interrupt gate. */
@ -257,7 +259,7 @@ void idt_copy_vectors_pic(void)
idt_copy_vectors(gate_table_pic); idt_copy_vectors(gate_table_pic);
} }
void idt_init(void) static void idt_init(void)
{ {
idt_copy_vectors_pic(); idt_copy_vectors_pic();
idt_copy_vectors(gate_table_exceptions); idt_copy_vectors(gate_table_exceptions);
@ -270,7 +272,7 @@ void idt_reload(void)
x86_lidt(&idt_desc); x86_lidt(&idt_desc);
} }
multiboot_module_t *bootmod(int pnr) static multiboot_module_t *bootmod(int pnr)
{ {
int i; int i;
@ -284,8 +286,8 @@ multiboot_module_t *bootmod(int pnr)
int p; int p;
p = i - NR_TASKS; p = i - NR_TASKS;
if(image[i].proc_nr == pnr) { if(image[i].proc_nr == pnr) {
assert(p < MULTIBOOT_MAX_MODS); assert(p < (int) MULTIBOOT_MAX_MODS);
assert(p < kinfo.mbi.mods_count); assert(p < (int) kinfo.mbi.mods_count);
return &kinfo.module_list[p]; return &kinfo.module_list[p];
} }
} }
@ -295,7 +297,7 @@ multiboot_module_t *bootmod(int pnr)
int booting_cpu = 0; 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 /* this function is called by both prot_init by the BSP and
* the early AP booting code in mpx.S by secondary CPU's. * the early AP booting code in mpx.S by secondary CPU's.
@ -318,7 +320,7 @@ void prot_load_selectors(void)
/*===========================================================================* /*===========================================================================*
* prot_init * * prot_init *
*===========================================================================*/ *===========================================================================*/
void prot_init() void prot_init(void)
{ {
extern char k_boot_stktop; 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); 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_map(PG_ALLOCATEME, vaddr, vaddr+len, &kinfo);
pg_load(); pg_load();

View File

@ -212,23 +212,21 @@ clock_t get_monotonic(void)
/*===========================================================================* /*===========================================================================*
* set_timer * * set_timer *
*===========================================================================*/ *===========================================================================*/
void set_timer(tp, exp_time, watchdog) void set_timer(struct timer *tp, /* pointer to timer structure */
struct timer *tp; /* pointer to timer structure */ clock_t exp_time, /* expiration monotonic time */
clock_t exp_time; /* expiration monotonic time */ tmr_func_t watchdog_func) /* watchdog to be called */
tmr_func_t watchdog; /* watchdog to be called */
{ {
/* Insert the new timer in the active timers list. Always update the /* 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. * 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; next_timeout = clock_timers->tmr_exp_time;
} }
/*===========================================================================* /*===========================================================================*
* reset_timer * * reset_timer *
*===========================================================================*/ *===========================================================================*/
void reset_timer(tp) void reset_timer(struct timer *tp) /* pointer to timer structure */
struct timer *tp; /* pointer to timer structure */
{ {
/* The timer pointed to by 'tp' is no longer needed. Remove it from both the /* 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 * active and expired lists. Always update the next timeout time by setting

View File

@ -14,7 +14,7 @@
#define MAX_LOOP (NR_PROCS + NR_TASKS) #define MAX_LOOP (NR_PROCS + NR_TASKS)
int runqueues_ok_cpu(unsigned cpu) static int runqueues_ok_cpu(unsigned cpu)
{ {
int q, l = 0; int q, l = 0;
register struct proc *xp; register struct proc *xp;
@ -134,7 +134,7 @@ int runqueues_ok(void)
#endif #endif
char * const char *
rtsflagstr(const u32_t flags) rtsflagstr(const u32_t flags)
{ {
static char str[100]; static char str[100];
@ -161,7 +161,7 @@ rtsflagstr(const u32_t flags)
return str; return str;
} }
char * const char *
miscflagstr(const u32_t flags) miscflagstr(const u32_t flags)
{ {
static char str[100]; static char str[100];
@ -174,7 +174,7 @@ miscflagstr(const u32_t flags)
return str; return str;
} }
char * const char *
schedulerstr(struct proc *scheduler) schedulerstr(struct proc *scheduler)
{ {
if (scheduler != NULL) if (scheduler != NULL)

View File

@ -35,7 +35,7 @@ vir_bytes minix_kerninfo_user;
/* Process scheduling information and the kernel reentry count. */ /* Process scheduling information and the kernel reentry count. */
EXTERN struct proc *vmrequest; /* first process on vmrequest queue */ EXTERN struct proc *vmrequest; /* first process on vmrequest queue */
EXTERN unsigned lost_ticks; /* clock ticks counted outside clock task */ 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_kcall; /* process that made kernel call */
EXTERN struct proc *kbill_ipc; /* process that invoked ipc */ EXTERN struct proc *kbill_ipc; /* process that invoked ipc */

View File

@ -37,7 +37,7 @@ char *** _penviron;
/* Prototype declarations for PRIVATE functions. */ /* Prototype declarations for PRIVATE functions. */
static void announce(void); static void announce(void);
void bsp_finish_booting(void) __dead void bsp_finish_booting(void)
{ {
int i; int i;
#if SPROFILE #if SPROFILE
@ -114,12 +114,12 @@ void bsp_finish_booting(void)
/*===========================================================================* /*===========================================================================*
* kmain * * kmain *
*===========================================================================*/ *===========================================================================*/
void kmain(kinfo_t *local_cbi) __dead void kmain(kinfo_t *local_cbi)
{ {
/* Start the ball rolling. */ /* Start the ball rolling. */
struct boot_image *ip; /* boot image pointer */ struct boot_image *ip; /* boot image pointer */
register struct proc *rp; /* process pointer */ register struct proc *rp; /* process pointer */
register int i, j; unsigned int i, j;
/* save a global copy of the boot parameters */ /* save a global copy of the boot parameters */
memcpy(&kinfo, local_cbi, sizeof(kinfo)); memcpy(&kinfo, local_cbi, sizeof(kinfo));
@ -395,12 +395,12 @@ void minix_shutdown(timer_t *tp)
/*===========================================================================* /*===========================================================================*
* cstart * * cstart *
*===========================================================================*/ *===========================================================================*/
void cstart() void cstart(void)
{ {
/* Perform system initializations prior to calling main(). Most settings are /* Perform system initializations prior to calling main(). Most settings are
* determined with help of the environment strings passed by MINIX' loader. * 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; int h;
/* low-level initialization */ /* low-level initialization */
@ -469,7 +469,7 @@ void cstart()
* get_value * * get_value *
*===========================================================================*/ *===========================================================================*/
char *get_value( static const char *get_value(
const char *params, /* boot monitor parameters */ const char *params, /* boot monitor parameters */
const char *name /* key to look up */ const char *name /* key to look up */
) )
@ -478,9 +478,9 @@ char *get_value(
* usual environment array. * usual environment array.
*/ */
register const char *namep; 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++) for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
; ;
if (*namep == '\0' && *envp == '=') return(envp + 1); if (*namep == '\0' && *envp == '=') return(envp + 1);
@ -493,7 +493,7 @@ char *get_value(
/*===========================================================================* /*===========================================================================*
* env_get * * env_get *
*===========================================================================*/ *===========================================================================*/
char *env_get(const char *name) const char *env_get(const char *name)
{ {
return get_value(kinfo.param_buf, name); return get_value(kinfo.param_buf, name);
} }

View File

@ -226,7 +226,7 @@ static void idle(void)
/*===========================================================================* /*===========================================================================*
* switch_to_user * * switch_to_user *
*===========================================================================*/ *===========================================================================*/
void switch_to_user(void) __dead void switch_to_user(void)
{ {
/* This function is called an instant before proc_ptr is /* This function is called an instant before proc_ptr is
* to be scheduled again. * 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 result; /* the system call's result */
int src_dst_p; /* Process slot number */ int src_dst_p; /* Process slot number */
char *callname; const char *callname;
/* Check destination. RECEIVE is the only call that accepts ANY (in addition /* 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 * 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 * * deadlock *
*===========================================================================*/ *===========================================================================*/
static int deadlock(function, cp, src_dst_e) static int deadlock(int function, register struct proc *cp,
int function; /* trap number */ endpoint_t src_dst_e)
register struct proc *cp; /* pointer to caller */
endpoint_t src_dst_e; /* src or dst process */
{ {
/* Check for deadlock. This can happen if 'caller_ptr' and 'src_dst' have /* 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 * 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 * * try_async *
*===========================================================================*/ *===========================================================================*/
static int try_async(caller_ptr) static int try_async(struct proc *caller_ptr)
struct proc *caller_ptr;
{ {
int r; int r;
struct priv *privp; struct priv *privp;
@ -1752,15 +1749,10 @@ struct proc *endpoint_lookup(endpoint_t e)
* isokendpt_f * * isokendpt_f *
*===========================================================================*/ *===========================================================================*/
#if DEBUG_ENABLE_IPC_WARNINGS #if DEBUG_ENABLE_IPC_WARNINGS
int isokendpt_f(file, line, e, p, fatalflag) int isokendpt_f(const char *file, int line, endpoint_t e, int *p, const int fatalflag)
const char *file;
int line;
#else #else
int isokendpt_f(e, p, fatalflag) int isokendpt_f(endpoint_t e, int *p, const int fatalflag)
#endif #endif
endpoint_t e;
int *p;
const int fatalflag;
{ {
int ok = 0; int ok = 0;
/* Convert an endpoint number into a process number. /* Convert an endpoint number into a process number.
@ -1895,7 +1887,7 @@ void release_fpu(struct proc * p) {
*fpu_owner_ptr = NULL; *fpu_owner_ptr = NULL;
} }
void ser_dump_proc() void ser_dump_proc(void)
{ {
struct proc *pp; struct proc *pp;

View File

@ -47,6 +47,7 @@ void kmain(kinfo_t *cbi);
void prepare_shutdown(int how); void prepare_shutdown(int how);
__dead void minix_shutdown(struct timer *tp); __dead void minix_shutdown(struct timer *tp);
void bsp_finish_booting(void); void bsp_finish_booting(void);
void cstart(void);
/* proc.c */ /* proc.c */
@ -79,10 +80,11 @@ void increase_proc_signals(struct proc *p);
void flag_account(struct proc *p, int flag); void flag_account(struct proc *p, int flag);
int try_deliver_senda(struct proc *caller_ptr, asynmsg_t *table, size_t int try_deliver_senda(struct proc *caller_ptr, asynmsg_t *table, size_t
size); size);
void copr_not_available_handler(void);
/* start.c */ /* start.c */
void cstart(); void cstart(void);
char *env_get(const char *key); const char *env_get(const char *key);
/* system.c */ /* system.c */
int get_priv(register struct proc *rc, int proc_type); 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) #define runqueues_ok_local() runqueues_ok_cpu(cpuid)
int runqueues_ok_cpu(unsigned cpu); int runqueues_ok_cpu(unsigned cpu);
#endif #endif
char *rtsflagstr(u32_t flags); const char *rtsflagstr(u32_t flags);
char *miscflagstr(u32_t flags); const char *miscflagstr(u32_t flags);
char *schedulerstr(struct proc *scheduler); const char *schedulerstr(struct proc *scheduler);
/* prints process information */ /* prints process information */
void print_proc(struct proc *pp); void print_proc(struct proc *pp);
/* prints the given process and recursively all processes it depends on */ /* prints the given process and recursively all processes it depends on */
@ -148,8 +150,8 @@ void stop_profile_clock(void);
#endif #endif
/* functions defined in architecture-dependent files. */ /* functions defined in architecture-dependent files. */
void prot_init(); void prot_init(void);
void arch_post_init(); void arch_post_init(void);
void arch_set_secondary_ipc_return(struct proc *, u32_t val); void arch_set_secondary_ipc_return(struct proc *, u32_t val);
phys_bytes phys_copy(phys_bytes source, phys_bytes dest, phys_bytes phys_bytes phys_copy(phys_bytes source, phys_bytes dest, phys_bytes
count); count);

View File

@ -267,9 +267,7 @@ void system_init(void)
/*===========================================================================* /*===========================================================================*
* get_priv * * get_priv *
*===========================================================================*/ *===========================================================================*/
int get_priv(rc, priv_id) int get_priv(register struct proc *rc, int priv_id)
register struct proc *rc; /* new (child) process pointer */
int priv_id; /* privilege id */
{ {
/* Allocate a new privilege structure for a system process. Privilege ids /* Allocate a new privilege structure for a system process. Privilege ids
* can be assigned either statically or dynamically. * can be assigned either statically or dynamically.
@ -363,16 +361,16 @@ int send_sig(endpoint_t ep, int sig_nr)
* send a notification with source SYSTEM. * send a notification with source SYSTEM.
*/ */
register struct proc *rp; register struct proc *rp;
struct priv *priv; struct priv *privs;
int proc_nr; int proc_nr;
if(!isokendpt(ep, &proc_nr) || isemptyn(proc_nr)) if(!isokendpt(ep, &proc_nr) || isemptyn(proc_nr))
return EINVAL; return EINVAL;
rp = proc_addr(proc_nr); rp = proc_addr(proc_nr);
priv = priv(rp); privs = priv(rp);
if(!priv) return ENOENT; if(!privs) return ENOENT;
sigaddset(&priv->s_sig_pending, sig_nr); sigaddset(&privs->s_sig_pending, sig_nr);
increase_proc_signals(rp); increase_proc_signals(rp);
mini_notify(proc_addr(SYSTEM), rp->p_endpoint); mini_notify(proc_addr(SYSTEM), rp->p_endpoint);
@ -382,9 +380,7 @@ int send_sig(endpoint_t ep, int sig_nr)
/*===========================================================================* /*===========================================================================*
* cause_sig * * cause_sig *
*===========================================================================*/ *===========================================================================*/
void cause_sig(proc_nr, sig_nr) void cause_sig(proc_nr_t proc_nr, int sig_nr)
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: /* A system process wants to send a signal to a process. Examples are:
* - HARDWARE wanting to cause a SIGSEGV after a CPU exception * - HARDWARE wanting to cause a SIGSEGV after a CPU exception
@ -493,8 +489,7 @@ static void clear_ipc(
/*===========================================================================* /*===========================================================================*
* clear_endpoint * * clear_endpoint *
*===========================================================================*/ *===========================================================================*/
void clear_endpoint(rc) void clear_endpoint(struct proc *rc)
register struct proc *rc; /* slot of process to clean up */
{ {
if(isemptyp(rc)) panic("clear_proc: empty process: %d", rc->p_endpoint); if(isemptyp(rc)) panic("clear_proc: empty process: %d", rc->p_endpoint);
@ -526,9 +521,7 @@ register struct proc *rc; /* slot of process to clean up */
/*===========================================================================* /*===========================================================================*
* clear_ipc_refs * * clear_ipc_refs *
*===========================================================================*/ *===========================================================================*/
void clear_ipc_refs(rc, caller_ret) void clear_ipc_refs(register struct proc *rc, int caller_ret)
register struct proc *rc; /* slot of process to clean up */
int caller_ret; /* code to return on callers */
{ {
/* Clear IPC references for a given process slot. */ /* Clear IPC references for a given process slot. */
struct proc *rp; /* iterate over process table */ struct proc *rp; /* iterate over process table */

View File

@ -22,8 +22,8 @@ int do_devio(struct proc * caller, message * m_ptr)
struct priv *privp; struct priv *privp;
port_t port; port_t port;
struct io_range *iorp; struct io_range *iorp;
int i, size, nr_io_range; unsigned int i, size, nr_io_range;
int io_type, io_dir; unsigned int io_type, io_dir;
io_type = m_ptr->DIO_REQUEST & _DIO_TYPEMASK; io_type = m_ptr->DIO_REQUEST & _DIO_TYPEMASK;
io_dir = m_ptr->DIO_REQUEST & _DIO_DIRMASK; io_dir = m_ptr->DIO_REQUEST & _DIO_DIRMASK;

View File

@ -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 /* Request system information to be copied to caller's address space. This
* call simply copies entire data structures to the caller. * call simply copies entire data structures to the caller.
*/ */
size_t length; int length;
vir_bytes src_vir; vir_bytes src_vir;
int nr_e, nr, r; int nr_e, nr, r;
int wipe_rnd_bin = -1; int wipe_rnd_bin = -1;

View File

@ -26,7 +26,7 @@ int do_irqctl(struct proc * caller, message * m_ptr)
/* Dismember the request message. */ /* Dismember the request message. */
int irq_vec; int irq_vec;
int irq_hook_id; int irq_hook_id;
int notify_id; unsigned int notify_id;
int r = OK; int r = OK;
int i; int i;
irq_hook_t *hook_ptr; irq_hook_t *hook_ptr;
@ -141,8 +141,7 @@ int do_irqctl(struct proc * caller, message * m_ptr)
/*===========================================================================* /*===========================================================================*
* generic_handler * * generic_handler *
*===========================================================================*/ *===========================================================================*/
static int generic_handler(hook) static int generic_handler(irq_hook_t *hook)
irq_hook_t *hook;
{ {
/* This function handles hardware interrupt in a simple and generic way. All /* 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 * interrupts are transformed into messages to a driver. The IRQ line will be

View File

@ -35,7 +35,7 @@ int do_privctl(struct proc * caller, message * m_ptr)
int i, r; int i, r;
struct io_range io_range; struct io_range io_range;
struct minix_mem_range mem_range; struct minix_mem_range mem_range;
struct priv priv; struct priv privs;
int irq; int irq;
/* Check whether caller is allowed to make this call. Privileged proceses /* 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 */ /* Copy privilege structure from caller */
if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR, 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; return r;
/* See if the caller wants to assign a static privilege id. */ /* See if the caller wants to assign a static privilege id. */
if(!(priv.s_flags & DYN_PRIV_ID)) { if(!(privs.s_flags & DYN_PRIV_ID)) {
priv_id = priv.s_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_id = priv_id; /* restore privilege id */
priv(rp)->s_proc_nr = proc_nr; /* reassociate process nr */ 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_notify_pending.chunk[i] = 0; /* - notifications */
priv(rp)->s_int_pending = 0; /* - interrupts */ priv(rp)->s_int_pending = 0; /* - interrupts */
(void) sigemptyset(&priv(rp)->s_sig_pending); /* - signals */ (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); fill_sendto_mask(rp, &map);
kcalls = DSRV_KC; /* allowed kernel calls */ 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)); 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. */ /* Override defaults if the caller has supplied a privilege structure. */
if (m_ptr->CTL_ARG_PTR) if (m_ptr->CTL_ARG_PTR)
{ {
if((r = update_priv(rp, &priv)) != OK) { if((r = update_priv(rp, &privs)) != OK) {
return r; return r;
} }
} }
@ -298,11 +298,11 @@ int do_privctl(struct proc * caller, message * m_ptr)
/* Copy privilege structure from caller */ /* Copy privilege structure from caller */
if((r=data_copy(caller->p_endpoint, (vir_bytes) m_ptr->CTL_ARG_PTR, 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; return r;
/* Override settings in existing privilege structure. */ /* Override settings in existing privilege structure. */
if((r = update_priv(rp, &priv)) != OK) { if((r = update_priv(rp, &privs)) != OK) {
return r; return r;
} }
@ -317,25 +317,25 @@ int do_privctl(struct proc * caller, message * m_ptr)
/*===========================================================================* /*===========================================================================*
* update_priv * * 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. */ /* Update the privilege structure of a given process. */
int i; int i;
/* Copy s_flags and signal managers. */ /* Copy s_flags and signal managers. */
priv(rp)->s_flags = priv->s_flags; priv(rp)->s_flags = privs->s_flags;
priv(rp)->s_sig_mgr = priv->s_sig_mgr; priv(rp)->s_sig_mgr = privs->s_sig_mgr;
priv(rp)->s_bak_sig_mgr = priv->s_bak_sig_mgr; priv(rp)->s_bak_sig_mgr = privs->s_bak_sig_mgr;
/* Copy IRQs. */ /* Copy IRQs. */
if(priv->s_flags & CHECK_IRQ) { if(privs->s_flags & CHECK_IRQ) {
if (priv->s_nr_irq < 0 || priv->s_nr_irq > NR_IRQ) if (privs->s_nr_irq < 0 || privs->s_nr_irq > NR_IRQ)
return EINVAL; return EINVAL;
priv(rp)->s_nr_irq= priv->s_nr_irq; priv(rp)->s_nr_irq= privs->s_nr_irq;
for (i= 0; i<priv->s_nr_irq; i++) for (i= 0; i<privs->s_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 #if PRIV_DEBUG
printf("do_privctl: adding IRQ %d for %d\n", printf("do_privctl: adding IRQ %d for %d\n",
priv(rp)->s_irq_tab[i], rp->p_endpoint); 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. */ /* Copy I/O ranges. */
if(priv->s_flags & CHECK_IO_PORT) { if(privs->s_flags & CHECK_IO_PORT) {
if (priv->s_nr_io_range < 0 || priv->s_nr_io_range > NR_IO_RANGE) if (privs->s_nr_io_range < 0 || privs->s_nr_io_range > NR_IO_RANGE)
return EINVAL; return EINVAL;
priv(rp)->s_nr_io_range= priv->s_nr_io_range; priv(rp)->s_nr_io_range= privs->s_nr_io_range;
for (i= 0; i<priv->s_nr_io_range; i++) for (i= 0; i<privs->s_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 #if PRIV_DEBUG
printf("do_privctl: adding I/O range [%x..%x] for %d\n", printf("do_privctl: adding I/O range [%x..%x] for %d\n",
priv(rp)->s_io_tab[i].ior_base, 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. */ /* Copy memory ranges. */
if(priv->s_flags & CHECK_MEM) { if(privs->s_flags & CHECK_MEM) {
if (priv->s_nr_mem_range < 0 || priv->s_nr_mem_range > NR_MEM_RANGE) if (privs->s_nr_mem_range < 0 || privs->s_nr_mem_range > NR_MEM_RANGE)
return EINVAL; return EINVAL;
priv(rp)->s_nr_mem_range= priv->s_nr_mem_range; priv(rp)->s_nr_mem_range= privs->s_nr_mem_range;
for (i= 0; i<priv->s_nr_mem_range; i++) for (i= 0; i<privs->s_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 #if PRIV_DEBUG
printf("do_privctl: adding mem range [%x..%x] for %d\n", printf("do_privctl: adding mem range [%x..%x] for %d\n",
priv(rp)->s_mem_tab[i].mr_base, 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. */ /* Copy trap mask. */
priv(rp)->s_trap_mask = priv->s_trap_mask; priv(rp)->s_trap_mask = privs->s_trap_mask;
/* Copy target mask. */ /* Copy target mask. */
#if PRIV_DEBUG #if PRIV_DEBUG
printf("do_privctl: Setting ipc target mask for %d:"); printf("do_privctl: Setting ipc target mask for %d:");
for (i=0; i < NR_SYS_PROCS; i += BITCHUNK_BITS) { 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"); printf("\n");
#endif #endif
fill_sendto_mask(rp, &priv->s_ipc_to); fill_sendto_mask(rp, &privs->s_ipc_to);
#if PRIV_DEBUG #if PRIV_DEBUG
printf("do_privctl: Set ipc target mask for %d:"); printf("do_privctl: Set ipc target mask for %d:");
@ -400,7 +400,7 @@ static int update_priv(struct proc *rp, struct priv *priv)
#endif #endif
/* Copy kernel call mask. */ /* 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)); sizeof(priv(rp)->s_k_call_mask));
return OK; return OK;

View File

@ -31,15 +31,10 @@ static int safecopy(struct proc *, endpoint_t, endpoint_t,
/*===========================================================================* /*===========================================================================*
* verify_grant * * verify_grant *
*===========================================================================*/ *===========================================================================*/
int verify_grant(granter, grantee, grant, bytes, access, int verify_grant(endpoint_t granter, endpoint_t grantee,
offset_in, offset_result, e_granter) cp_grant_id_t grant, vir_bytes bytes,
endpoint_t granter, grantee; /* copyee, copyer */ int access, vir_bytes offset_in,
cp_grant_id_t grant; /* grant id */ vir_bytes *offset_result, endpoint_t *e_granter)
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) */
{ {
static cp_grant_t g; static cp_grant_t g;
static int proc_nr; static int proc_nr;
@ -225,16 +220,9 @@ endpoint_t *e_granter; /* new granter (magic grants) */
/*===========================================================================* /*===========================================================================*
* safecopy * * safecopy *
*===========================================================================*/ *===========================================================================*/
static int safecopy(caller, granter, grantee, grantid, bytes, static int safecopy(struct proc * caller, endpoint_t granter,
g_offset, addr, access) endpoint_t grantee, cp_grant_id_t grantid, size_t bytes,
struct proc * caller; vir_bytes g_offset, vir_bytes addr, int access)
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 struct vir_addr v_src, v_dst; static struct vir_addr v_src, v_dst;
static vir_bytes v_offset; static vir_bytes v_offset;

View File

@ -71,7 +71,7 @@ int do_sigsend(struct proc * caller, message * m_ptr)
/* Initialize the sigframe structure. */ /* Initialize the sigframe structure. */
frp = (struct sigframe *) scp - 1; frp = (struct sigframe *) scp - 1;
fr.sf_scpcopy = scp; 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; fr.sf_fp = rp->p_reg.fp;
rp->p_reg.fp = (reg_t) &frp->sf_fp; rp->p_reg.fp = (reg_t) &frp->sf_fp;
fr.sf_scp = scp; fr.sf_scp = scp;
@ -79,7 +79,7 @@ int do_sigsend(struct proc * caller, message * m_ptr)
fpu_sigcontext(rp, &fr, &sc); fpu_sigcontext(rp, &fr, &sc);
fr.sf_signo = smsg.sm_signo; fr.sf_signo = smsg.sm_signo;
fr.sf_retadr = (void (*)()) smsg.sm_sigreturn; fr.sf_retadr = (void (*)(void)) smsg.sm_sigreturn;
#if defined(__arm__) #if defined(__arm__)
/* use the ARM link register to set the return address from the signal /* use the ARM link register to set the return address from the signal

View File

@ -16,7 +16,8 @@ int do_sysctl(struct proc * caller, message * m_ptr)
{ {
vir_bytes len, buf; vir_bytes len, buf;
static char mybuf[DIAG_BUFSIZE]; static char mybuf[DIAG_BUFSIZE];
int s, i, proc_nr; int s, proc_nr;
unsigned int i;
switch (m_ptr->SYSCTL_CODE) { switch (m_ptr->SYSCTL_CODE) {
case SYSCTL_CODE_DIAG: case SYSCTL_CODE_DIAG:

View File

@ -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_type = m_ptr->UMAP_SEG & SEGMENT_TYPE;
int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX; int seg_index = m_ptr->UMAP_SEG & SEGMENT_INDEX;
vir_bytes offset = m_ptr->CP_SRC_ADDR; 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; int endpt = (int) m_ptr->CP_SRC_ENDPT;
endpoint_t grantee = (endpoint_t) m_ptr->CP_DST_ENDPT; endpoint_t grantee = (endpoint_t) m_ptr->CP_DST_ENDPT;
int proc_nr, proc_nr_grantee; int proc_nr, proc_nr_grantee;

View File

@ -31,11 +31,11 @@ int do_vdevio(struct proc * caller, message * m_ptr)
* that I/O batch from being interrrupted. * that I/O batch from being interrrupted.
* This is the counterpart of do_devio, which performs a single device I/O. * 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 */ int io_in; /* true if input */
size_t bytes; /* # bytes to be copied */ size_t bytes; /* # bytes to be copied */
port_t port; 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; int io_dir, io_type;
struct priv *privp; struct priv *privp;
struct io_range *iorp; struct io_range *iorp;

View File

@ -80,8 +80,7 @@ int do_vtimer(struct proc * caller, message * m_ptr)
/*===========================================================================* /*===========================================================================*
* vtimer_check * * vtimer_check *
*===========================================================================*/ *===========================================================================*/
void vtimer_check(rp) void vtimer_check(struct proc *rp)
struct proc *rp; /* pointer to the process */
{ {
/* This is called from the clock task, so we can be interrupted by the clock /* 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 * interrupt, but not by the system task. Therefore we only have to protect

View File

@ -44,24 +44,24 @@
struct boot_image image[NR_BOOT_PROCS] = { struct boot_image image[NR_BOOT_PROCS] = {
/* process nr, flags, stack size, name */ /* process nr, flags, stack size, name */
{ASYNCM, "asyncm"}, {ASYNCM, "asyncm", 0, 0, 0},
{IDLE, "idle" }, {IDLE, "idle" , 0, 0, 0},
{CLOCK, "clock" }, {CLOCK, "clock" , 0, 0, 0},
{SYSTEM, "system"}, {SYSTEM, "system", 0, 0, 0},
{HARDWARE, "kernel"}, {HARDWARE, "kernel", 0, 0, 0},
{DS_PROC_NR, "ds" }, {DS_PROC_NR, "ds" , 0, 0, 0},
{RS_PROC_NR, "rs" }, {RS_PROC_NR, "rs" , 0, 0, 0},
{PM_PROC_NR, "pm" }, {PM_PROC_NR, "pm" , 0, 0, 0},
{SCHED_PROC_NR, "sched" }, {SCHED_PROC_NR, "sched" , 0, 0, 0},
{VFS_PROC_NR, "vfs" }, {VFS_PROC_NR, "vfs" , 0, 0, 0},
{MEM_PROC_NR, "memory"}, {MEM_PROC_NR, "memory", 0, 0, 0},
{LOG_PROC_NR, "log" }, {LOG_PROC_NR, "log" , 0, 0, 0},
{TTY_PROC_NR, "tty" }, {TTY_PROC_NR, "tty" , 0, 0, 0},
{MFS_PROC_NR, "mfs" }, {MFS_PROC_NR, "mfs" , 0, 0, 0},
{VM_PROC_NR, "vm" }, {VM_PROC_NR, "vm" , 0, 0, 0},
{PFS_PROC_NR, "pfs" }, {PFS_PROC_NR, "pfs" , 0, 0, 0},
{INIT_PROC_NR, "init" }, {INIT_PROC_NR, "init" , 0, 0, 0},
}; };

View File

@ -14,7 +14,7 @@
#include <minix/sys_config.h> #include <minix/sys_config.h>
#define ARE_PANICING 0xDEADC0FF #define ARE_PANICING (int) 0x0DEADC0F
/*===========================================================================* /*===========================================================================*
* panic * * panic *
@ -51,8 +51,7 @@ void panic(const char *fmt, ...)
/*===========================================================================* /*===========================================================================*
* kputc * * kputc *
*===========================================================================*/ *===========================================================================*/
void kputc(c) void kputc(int c) /* character to append */
int c; /* character to append */
{ {
/* Accumulate a single character for a kernel message. Send a notification /* Accumulate a single character for a kernel message. Send a notification
* to the output driver if an END_OF_KMESS is encountered. * to the output driver if an END_OF_KMESS is encountered.
@ -92,8 +91,7 @@ int c; /* character to append */
/*===========================================================================* /*===========================================================================*
* _exit * * _exit *
*===========================================================================*/ *===========================================================================*/
void _exit(e) void _exit(int e)
int e; /* error code */
{ {
panic("_exit called from within the kernel, should not happen. (err %i)", e); panic("_exit called from within the kernel, should not happen. (err %i)", e);
} }

View File

@ -10,9 +10,7 @@
#include <minix/sysutil.h> #include <minix/sysutil.h>
void void
__assert13(file, line, function, failedexpr) __assert13(const char *file, int line, const char *function, const char *failedexpr)
const char *file, *function, *failedexpr;
int line;
{ {
(void)printf("%s:%d: assert \"%s\" failed", file, line, failedexpr); (void)printf("%s:%d: assert \"%s\" failed", file, line, failedexpr);
if(function) printf(", function \"%s\"", function); if(function) printf(", function \"%s\"", function);
@ -22,9 +20,7 @@ __assert13(file, line, function, failedexpr)
} }
void void
__assert(file, line, failedexpr) __assert(const char *file, int line, const char *failedexpr)
const char *file, *failedexpr;
int line;
{ {
__assert13(file, line, NULL, failedexpr); __assert13(file, line, NULL, failedexpr);

View File

@ -6,6 +6,7 @@ Created: Jan 19, 1993 by Philip Homburg
Copyright 1995 Philip Homburg Copyright 1995 Philip Homburg
*/ */
#include <minix/sysutil.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -10,7 +10,7 @@ void kputc(int c);
#define count_kputc(c) do { charcount++; putf((c), farg); } while(0) #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; int c, charcount = 0;
enum { LEFT, RIGHT } adjust; 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; int width, max, len, base;
static char X2C_tab[]= "0123456789ABCDEF"; static char X2C_tab[]= "0123456789ABCDEF";
static char x2c_tab[]= "0123456789abcdef"; static char x2c_tab[]= "0123456789abcdef";
char *x2c; char *x2c, *pp;
char *p; const char *p;
long long i; long long i;
unsigned long long u = 0; unsigned long long u = 0;
char temp[8 * sizeof(long long) / 3 + 2]; 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; case INT: u= va_arg(argp, unsigned int); break;
} }
int2ascii: int2ascii:
p= temp + sizeof(temp)-1; pp= temp + sizeof(temp)-1;
*p= 0; *pp= 0;
do { do {
*--p= x2c[(ptrdiff_t) (u % base)]; *--pp= x2c[(ptrdiff_t) (u % base)];
} while ((u /= base) > 0); } while ((u /= base) > 0);
p = pp;
goto string_length; goto string_length;
/* A character. */ /* A character. */
case 'c': case 'c':
p= temp; p = pp= temp;
*p= va_arg(argp, int); *pp= va_arg(argp, int);
len= 1; len= 1;
goto string_print; goto string_print;
/* Simply a percent. */ /* Simply a percent. */
case '%': case '%':
p= temp; pp = temp;
*p= '%'; *pp= '%';
len= 1; len= 1;
p = pp;
goto string_print; goto string_print;
/* A string. The other cases will join in here. */ /* 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; return charcount;
} }
#define vprintf _vprintf
#define vfprintf _vfprintf
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <assert.h> #include <assert.h>
#include <unistd.h> #include <unistd.h>
@ -211,12 +216,12 @@ __xfputc(int c, void *arg)
kputc(c); kputc(c);
} }
int _vprintf(const char *fmt, va_list argp) int vprintf(const char *fmt, va_list argp)
{ {
return __fvprintf(__xfputc, fmt, argp, stdout); 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); return __fvprintf(__xfputc, fmt, argp, fp);
} }