+
+#include <string.h>
+
#include "kernel/kernel.h"
#include "acpi.h"
+#include "arch_proto.h"
typedef int ((* acpi_read_t)(phys_bytes addr, void * buff, size_t size));
return tb->length;
}
-PRIVATE phys_bytes acpi_get_table_base(const char * name)
+PUBLIC phys_bytes acpi_get_table_base(const char * name)
{
int i;
return (phys_bytes) NULL;
}
-PRIVATE size_t acpi_get_table_length(const char * name)
+PUBLIC size_t acpi_get_table_length(const char * name)
{
int i;
return NULL;
}
+#if 0
PRIVATE void * acpi_madt_get_item(struct acpi_madt_hdr * hdr,
unsigned idx)
{
return NULL;
}
+#endif
+
PRIVATE int acpi_rsdp_test(void * buff)
{
struct acpi_rsdp * rsdp = (struct acpi_rsdp *) buff;
#define IOAPIC_IOREGSEL 0x0
#define IOAPIC_IOWIN 0x10
-PUBLIC u32_t ioapic_read(u32_t ioa_base, u32_t reg)
+PRIVATE u32_t ioapic_read(u32_t ioa_base, u32_t reg)
{
*((u32_t *)(ioa_base + IOAPIC_IOREGSEL)) = (reg & 0xff);
return *(u32_t *)(ioa_base + IOAPIC_IOWIN);
ioapic_write(ioapic_addr, IOAPIC_REDIR_TABLE + pin * 2, lo);
}
+#if 0
PRIVATE void ioapic_redirt_entry_read(void * ioapic_addr,
int entry,
u32_t *hi,
*hi = ioapic_read((u32_t)ioapic_addr, (u8_t) (IOAPIC_REDIR_TABLE + entry * 2 + 1));
}
+#endif
PRIVATE void ioapic_redirt_entry_write(void * ioapic_addr,
int entry,
PRIVATE int lapic_disable_in_msr(void)
{
- u32_t addr, msr_hi, msr_lo;
+ u32_t msr_hi, msr_lo;
ia32_msr_read(IA32_APIC_BASE, &msr_hi, &msr_lo);
PRIVATE int lapic_enable_in_msr(void)
{
- u32_t addr, msr_hi, msr_lo;
+ u32_t msr_hi, msr_lo;
ia32_msr_read(IA32_APIC_BASE, &msr_hi, &msr_lo);
#if 0
+ u32_t addr;
/*FIXME this is a problem on AP */
/*
* FIXME if the location is different (unlikely) then the one we expect,
switch to paging */
_PROTOTYPE (int lapic_enable, (unsigned cpu));
+_PROTOTYPE (void ioapic_unmask_irq, (unsigned irq));
+_PROTOTYPE (void ioapic_mask_irq, (unsigned irq));
+_PROTOTYPE (void ioapic_reset_pic, (void));
EXTERN int ioapic_enabled;
EXTERN unsigned nioapics;
PUBLIC void cycles_accounting_init(void)
{
- unsigned cpu = cpuid;
-
read_tsc_64(get_cpu_var_ptr(cpu, tsc_ctr_switch));
make_zero64(get_cpu_var(cpu, cpu_last_tsc));
PUBLIC void context_stop(struct proc * p)
{
- unsigned cpu = cpuid;
u64_t tsc, tsc_delta;
u64_t * __tsc_ctr_switch = get_cpulocal_var_ptr(tsc_ctr_switch);
-
#ifdef CONFIG_SMP
+ unsigned cpu = cpuid;
+
/*
* This function is called only if we switch from kernel to user or idle
* or back. Therefore this is a perfect location to place the big kernel
PUBLIC void context_stop_idle(void)
{
int is_idle;
+#ifdef CONFIG_SMP
unsigned cpu = cpuid;
+#endif
is_idle = get_cpu_var(cpu, cpu_is_idle);
get_cpu_var(cpu, cpu_is_idle) = 0;
u64_t tsc_delta, idle_delta, busy;
struct proc *idle;
short load;
+#ifdef CONFIG_SMP
unsigned cpu = cpuid;
+#endif
u64_t *last_tsc, *last_idle;
#define COLOR_BASE 0xB8000L
-PRIVATE void cons_setc(const int pos, const int c)
-{
- char ch;
-
- ch= c;
- phys_copy(vir2phys((vir_bytes)&ch), COLOR_BASE+(20*80+pos)*2, 1);
-}
-
-PRIVATE void cons_seth(int pos, int n)
-{
- n &= 0xf;
- if (n < 10)
- cons_setc(pos, '0'+n);
- else
- cons_setc(pos, 'A'+(n-10));
-}
-
/* Saved by mpx386.s into these variables. */
u32_t params_size, params_offset, mon_ds;
#include "debugreg.h"
-PRIVATE int breakpoint_set(phys_bytes linaddr, int bp, const int flags)
+PUBLIC int breakpoint_set(phys_bytes linaddr, int bp, const int flags)
{
unsigned long dr7, dr7flags;
#include "kernel/kernel.h"
#include "kernel/proc.h"
#include "arch_proto.h"
+#include "hw_intr.h"
#include <minix/portio.h>
#include <machine/cpu.h>
#define __HW_INTR_X86_H__
#include "kernel/kernel.h"
-_PROTOTYPE(int irq_8259_unmask,(int irq));
-_PROTOTYPE(int irq_8259_mask,(int irq));
-_PROTOTYPE(int irq_8259_eoi, (int irq));
+_PROTOTYPE(void irq_8259_unmask,(int irq));
+_PROTOTYPE(void irq_8259_mask,(int irq));
+_PROTOTYPE(void irq_8259_eoi, (int irq));
_PROTOTYPE(void irq_handle,(int irq));
_PROTOTYPE(void i8259_disable,(void));
+_PROTOTYPE(void eoi_8259_master,(void));
+_PROTOTYPE(void eoi_8259_slave,(void));
/*
* we don't use IO APIC if not configured for SMP as we cannot read any info
return v;
}
+#if 0
PRIVATE char *cr0_str(u32_t e)
{
static char str[80];
if(e) { strcat(str, " (++)"); }
return str;
}
+#endif
PUBLIC void vm_stop(void)
{
*===========================================================================*/
PUBLIC void delivermsg(struct proc *rp)
{
- phys_bytes addr;
int r;
assert(rp->p_misc_flags & MF_DELIVERMSG);
}
}
+#if 0
PRIVATE char *flagstr(u32_t e, const int dir)
{
static char str[80];
return;
}
+#endif
/*===========================================================================*
* lin_memset *
FORWARD _PROTOTYPE(void mb_print, (char *str));
-PRIVATE void mb_phys_move(u32_t src, u32_t dest, u32_t len)
-{
- char data[GRAN + 1];
- int i;
- /* Move upward (start moving from tail), block by block
- * len should be aligned to GRAN
- */
- if (len % GRAN) {
- mb_print("fatal: not aligned phys move");
- /* Spin here */
- while (1)
- ;
- }
-
- len /= GRAN;
- for (i = len - 1; i >= 0; i--) {
- mb_load_phymem(data, src + i * GRAN, GRAN);
- mb_save_phymem(data, dest + i * GRAN, GRAN);
- }
-}
-
PRIVATE void mb_itoa(u32_t val, char * out)
{
char ret[ITOA_BUFFER_SIZE];
PRIVATE void get_parameters(multiboot_info_t *mbi)
{
char mem_value[40], temp[ITOA_BUFFER_SIZE];
- int i, r, processor;
+ int i, processor;
int dev;
int ctrlr;
int disk, prim, sub;
/* Load boot image services into memory and save memory map */
for (i = 0; module < &mb_module_info[mods_count]; ++module, ++i) {
- char zero = 0;
-
r = read_header_elf((const char *)module->mod_start,
&text_vaddr, &text_paddr,
&text_filebytes, &text_membytes,
return base;
}
-/*===========================================================================*
- * phys2seg *
- *===========================================================================*/
-PRIVATE void phys2seg(u16_t *seg, vir_bytes *off, phys_bytes phys)
-{
-/* Return a segment selector and offset that can be used to reach a physical
- * address, for use by a driver doing memory I/O in the A0000 - DFFFF range.
- */
- *seg = FLAT_DS_SELECTOR;
- *off = (vir_bytes) phys;
-}
-
/*===========================================================================*
* init_dataseg *
*===========================================================================*/
rp->p_reg.ds = (DS_LDT_INDEX*DESC_SIZE) | TI | privilege;
}
+#if 0
/*===========================================================================*
* check_segments *
*===========================================================================*/
panic("wrong: %d", fail);
}
}
+#endif
/*===========================================================================*
* printseg *
{
if (init_local_timer(freq))
return -1;
+
+ return 0;
}
PUBLIC void print_proc(struct proc *pp)
{
- struct proc *depproc = NULL;
endpoint_t dep;
printf("%d: %s %d prio %d time %d/%d cycles 0x%x%08x cpu %2d "
#include "debug.h"
#include "clock.h"
#include "hw_intr.h"
+#include "arch_proto.h"
#ifdef CONFIG_SMP
#include "smp.h"
struct boot_image *ip; /* boot image pointer */
register struct proc *rp; /* process pointer */
register int i, j;
- phys_clicks text_base;
- vir_clicks text_clicks, data_clicks, st_clicks;
size_t argsz; /* size of arguments passed to crtso on stack */
#if !defined(__ELF__)
+ vir_clicks text_clicks, data_clicks, st_clicks;
+ phys_clicks text_base;
int hdrindex; /* index to array of a.out headers */
struct exec e_hdr; /* for a copy of an a.out header */
#endif
*/
register struct proc **xpp;
sys_map_t *map;
- int i, r, src_id, src_proc_nr, src_p;
+ int r, src_id, src_proc_nr, src_p;
assert(!(caller_ptr->p_misc_flags & MF_DELIVERMSG));
PRIVATE int try_one(struct proc *src_ptr, struct proc *dst_ptr)
{
/* Try to receive an asynchronous message from 'src_ptr' */
- int r = EAGAIN, done, do_notify, pending_recv = FALSE;
+ int r = EAGAIN, done, do_notify;
unsigned int flags, i;
size_t size;
endpoint_t dst;
{
/* Cancel asynchronous messages from src to dst, because dst is not interested
* in them (e.g., dst has been restarted) */
- int done, do_notify, pending_recv = FALSE;
+ int done, do_notify;
unsigned int flags, i;
size_t size;
endpoint_t dst;
rm_irq_handler(&profile_clock_hook);
}
-PRIVATE sprof_save_sample(struct proc * p, void * pc)
+PRIVATE void sprof_save_sample(struct proc * p, void * pc)
{
struct sprof_sample *s;
sprof_info.mem_used += sizeof(struct sprof_sample);
}
-PRIVATE sprof_save_proc(struct proc * p)
+PRIVATE void sprof_save_proc(struct proc * p)
{
struct sprof_proc * s;
_PROTOTYPE(void enable_fpu_exception, (void));
_PROTOTYPE(void disable_fpu_exception, (void));
_PROTOTYPE(void release_fpu, (struct proc * p));
+_PROTOTYPE(void arch_pause,(void));
+_PROTOTYPE(short cpu_load, (void));
/* utility.c */
_PROTOTYPE( void cpu_print_freq, (unsigned cpu));
*/
PRIVATE int (*call_vec[NR_SYS_CALLS])(struct proc * caller, message *m_ptr);
-#define map(call_nr, handler) \
- {extern int dummy[NR_SYS_CALLS>(unsigned)(call_nr-KERNEL_CALL) ? 1:-1];} \
- call_vec[(call_nr-KERNEL_CALL)] = (handler)
+#define map(call_nr, handler) \
+ { int call_index = call_nr-KERNEL_CALL; \
+ assert(call_index >= 0 && call_index < NR_SYS_CALLS); \
+ call_vec[call_index] = (handler) ; }
PRIVATE void kernel_call_finish(struct proc * caller, message *msg, int result)
{
vir_bytes src_vir;
int nr_e, nr, r;
int wipe_rnd_bin = -1;
+#if !defined(__ELF__)
struct exec e_hdr;
+#endif
/* Set source address and length based on request type. */
switch (m_ptr->I_REQUEST) {
*/
#include "kernel/system.h"
+#include "watchdog.h"
#if SPROFILE
/* user address to write info struct */
PRIVATE vir_bytes sprof_info_addr_vir;
-PRIVATE clean_seen_flag(void)
+PRIVATE void clean_seen_flag(void)
{
int i;
/* Declare some local functions. */
FORWARD _PROTOTYPE(void get_work, (message *m_in) );
-FORWARD _PROTOTYPE(void cch_check, (void) );
FORWARD _PROTOTYPE( void reply, (endpoint_t who, message *m_out) );
/* SEF functions and variables. */
error = EINVAL;
} else {
error = (*fs_call_vec[ind])();
- /*cch_check();*/
}
fs_m_out.m_type = error;
if (OK != send(who, m_out)) /* send the message */
printf("ext2(%d) was unable to send reply\n", SELF_E);
}
-
-
-/*===========================================================================*
- * cch_check *
- *===========================================================================*/
-PRIVATE void cch_check(void)
-{
- int i;
-
- for (i = 0; i < NR_INODES; ++i) {
- if (inode[i].i_count != cch[i] && req_nr != REQ_GETNODE &&
- req_nr != REQ_PUTNODE && req_nr != REQ_READSUPER &&
- req_nr != REQ_MOUNTPOINT && req_nr != REQ_UNMOUNT &&
- req_nr != REQ_SYNC && req_nr != REQ_LOOKUP) {
- printf("ext2(%d) inode(%ul) cc: %d req_nr: %d\n", SELF_E,
- inode[i].i_num, inode[i].i_count - cch[i], req_nr);
- }
- cch[i] = inode[i].i_count;
- }
-}
*/
struct inode *rip;
struct buf *bp;
- int r;
assert(nr_bufs > 0);
assert(buf);
struct buf *bp;
struct ext2_disk_dir_desc *d_desc;
struct dirent *dep;
- char *cp;
ino = (ino_t) fs_m_in.REQ_INODE_NR;
gid = (gid_t) fs_m_in.REQ_GRANT;
{
/* Initialize this file server. Called at startup time.
*/
- message m;
int i, r;
/* Defaults */
sem_list[i] = sem_list[sem_list_nr];
}
+#if 0
PRIVATE void show_semaphore(void)
{
int i, j, k;
}
printf("\n");
}
+#endif
PRIVATE void remove_process(endpoint_t pt)
{
return OK;
}
+#if 0
PRIVATE void list_shm_ds(void)
{
int i;
shm_list[i].id,
shm_list[i].page);
}
+#endif
/*===========================================================================*
* is_shm_nil *
#include "inc.h"
#include <minix/vfsif.h>
-PRIVATE int dummyproc;
-
FORWARD _PROTOTYPE( int safe_io_conversion, (endpoint_t, cp_grant_id_t *,
int *, cp_grant_id_t *, int,
endpoint_t *, void **, int *,
{
struct buf *bp;
struct inode *rip;
- int scale, r;
#define MINBUFS 10
assert(blocksize > 0);
PRIVATE int bufs_heuristic(struct super_block *sp)
{
struct vm_stats_info vsi;
- int r, bufs;
+ int bufs;
u32_t btotal, bfree, bused, kbytes_used_fs,
kbytes_total_fs, kbcache, kb_fsmax;
u32_t kbytes_remain_mem;
/* Declare some local functions. */
FORWARD _PROTOTYPE(void get_work, (message *m_in) );
-FORWARD _PROTOTYPE(void cch_check, (void) );
FORWARD _PROTOTYPE( void reply, (endpoint_t who, message *m_out) );
/* SEF functions and variables. */
}
+#if 0
/*===========================================================================*
* cch_check *
*===========================================================================*/
cch[i] = inode[i].i_count;
}
}
+#endif
*===========================================================================*/
PUBLIC int do_getsysinfo()
{
- struct mproc *proc_addr;
vir_bytes src_addr, dst_addr;
- struct kinfo kinfo;
struct loadinfo loadinfo;
- static struct proc proctab[NR_PROCS+NR_TASKS];
size_t len;
- int s, r;
+ int s;
/* This call leaks important information (the contents of registers). */
if (mp->mp_effuid != 0)
PUBLIC int do_stop_scheduling(message *m_ptr)
{
register struct schedproc *rmp;
- int rv, proc_nr_n;
+ int proc_nr_n;
/* check who can send you requests */
if (!accept_message(m_ptr))
PUBLIC int do_start_scheduling(message *m_ptr)
{
register struct schedproc *rmp;
- int rv, proc_nr_n, parent_nr_n, nice;
+ int rv, proc_nr_n, parent_nr_n;
/* we can handle two kinds of messages here */
assert(m_ptr->m_type == SCHEDULING_START ||
{
struct schedproc *rmp;
int proc_nr;
- int rv;
for (proc_nr=0, rmp=schedproc; proc_nr < NR_PROCS; proc_nr++, rmp++) {
if (rmp->flags & IN_USE) {
/* Check all file descriptors in the set whether one is 'ready' now */
for (fd = 0; fd < nfds; fd++) {
- int type, ops, r;
+ int ops, r;
struct filp *f;
/* Again, check for involuntarily selected fd's */
* processes sharing a filp and both doing a select on that filp. */
f = se->filps[fd];
if ((f->filp_select_ops & ops) != ops) {
- int wantops, type, block;
+ int wantops;
wantops = (f->filp_select_ops |= ops);
r = do_select_request(se, fd, &wantops);
* select request to be sent again).
*/
for (fd = 0; fd < se->nfds; fd++) {
- int r, type, wantops, ops, block;
+ int r, wantops, ops;
if ((f = se->filps[fd]) == NULL) continue;
if (f->filp_select_flags & FSF_BUSY) /* Still waiting for */
continue; /* initial reply */