From: Ben Gras Date: Wed, 9 May 2012 16:34:40 +0000 (+0200) Subject: retire BIOS_SEG and umap_bios X-Git-Tag: v3.2.1~558 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch09.html?a=commitdiff_plain;h=cfb2d7bca570c930138a5b031d3401147bbada1a;p=minix.git retire BIOS_SEG and umap_bios . readbios call is now a physical copy with range check in the kernel call instead of BIOS_SEG+umap_bios . requires all access to physical memory in bios range to go through sys_readbios . drivers/dpeth: wasn't using it . adjusted printer --- diff --git a/drivers/dpeth/dp.c b/drivers/dpeth/dp.c index 1e17d7233..5b3bc0662 100644 --- a/drivers/dpeth/dp.c +++ b/drivers/dpeth/dp.c @@ -204,11 +204,7 @@ static void get_userdata_s(int user_proc, cp_grant_id_t grant, static void do_first_init(dpeth_t *dep, const dp_conf_t *dcp) { - if (dep->de_linmem != 0) { - dep->de_memsegm = BIOS_SEG; - /* phys2seg(&dep->de_memsegm, &dep->de_memoffs, dep->de_linmem); */ - } else - dep->de_linmem = 0xFFFF0000; + dep->de_linmem = 0xFFFF0000; /* Make sure statisics are cleared */ memset((void *) &(dep->de_stat), 0, sizeof(eth_stat_t)); diff --git a/drivers/dpeth/dp.h b/drivers/dpeth/dp.h index 06e0174aa..d36b5ea99 100644 --- a/drivers/dpeth/dp.h +++ b/drivers/dpeth/dp.h @@ -117,7 +117,6 @@ typedef struct dpeth { #define DEI_DEFAULT 0x8000 phys_bytes de_linmem; /* For boards using shared memory */ - unsigned short de_memsegm; vir_bytes de_memoffs; int de_ramsize; /* Size of on board memory */ int de_offset_page; /* Offset of shared memory page */ diff --git a/drivers/printer/printer.c b/drivers/printer/printer.c index 13067fbb1..107cedd22 100644 --- a/drivers/printer/printer.c +++ b/drivers/printer/printer.c @@ -366,9 +366,8 @@ static int do_probe(void) /* See if there is a printer at all. */ /* Get the base port for first printer. */ - if(sys_vircopy(SELF, BIOS_SEG, LPT1_IO_PORT_ADDR, - SELF, D, (vir_bytes) &port_base, LPT1_IO_PORT_SIZE) != OK) { - panic("do_initialize: sys_vircopy failed"); + if(sys_readbios(LPT1_IO_PORT_ADDR, &port_base, LPT1_IO_PORT_SIZE) != OK) { + panic("do_initialize: sys_readbios failed"); } /* If the port is zero, the parallel port is not available at all. */ diff --git a/etc/system.conf b/etc/system.conf index 3df6d709b..6bd3b3b2b 100644 --- a/etc/system.conf +++ b/etc/system.conf @@ -417,10 +417,10 @@ service printer system KILL # 6 UMAP # 14 - VIRCOPY # 15 IRQCTL # 19 DEVIO # 21 VDEVIO # 23 + READBIOS # 35 ; }; diff --git a/include/minix/const.h b/include/minix/const.h index 5db05a4dc..2342645e5 100644 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -63,8 +63,6 @@ #define D 1 /* proc[i].mem_map[D] is for data */ #define S 2 /* proc[i].mem_map[S] is for stack */ -#define BIOS_SEG 0x0200 /* flags indicating BIOS memory segment */ - #define PHYS_SEG 0x0400 /* flag indicating entire physical memory */ #define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 82bea78b5..e1d82e5e2 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -131,10 +131,6 @@ int sys_vtimer(endpoint_t proc_nr, int which, clock_t *newval, clock_t int sys_irqctl(int request, int irq_vec, int policy, int *irq_hook_id); /* Shorthands for sys_vircopy() and sys_physcopy() system calls. */ -#define sys_biosin(bios_vir, dst_vir, bytes) \ - sys_vircopy(SELF, BIOS_SEG, bios_vir, SELF, D, dst_vir, bytes) -#define sys_biosout(src_vir, bios_vir, bytes) \ - sys_vircopy(SELF, D, src_vir, SELF, BIOS_SEG, bios_vir, bytes) #define sys_datacopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \ sys_vircopy(src_proc, D, src_vir, dst_proc, D, dst_vir, bytes) #define sys_textcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \ diff --git a/kernel/arch/i386/do_readbios.c b/kernel/arch/i386/do_readbios.c index c2a8e21ca..e8cb08725 100644 --- a/kernel/arch/i386/do_readbios.c +++ b/kernel/arch/i386/do_readbios.c @@ -15,14 +15,25 @@ *===========================================================================*/ int do_readbios(struct proc * caller, message * m_ptr) { - struct vir_addr src, dst; - - src.segment = BIOS_SEG; + struct vir_addr src, dst; + vir_bytes len = m_ptr->RDB_SIZE, limit; + + src.segment = PHYS_SEG; dst.segment = D; src.offset = m_ptr->RDB_ADDR; dst.offset = (vir_bytes) m_ptr->RDB_BUF; src.proc_nr_e = NONE; dst.proc_nr_e = m_ptr->m_source; + limit = src.offset + len - 1; + +#define VINRANGE(v, a, b) ((a) <= (v) && (v) <= (b)) +#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) && + !USERRANGE(BASE_MEM_TOP, UPPER_MEM_END)) + return EPERM; + return virtual_copy_vmcheck(caller, &src, &dst, m_ptr->RDB_SIZE); } diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 3fdcb9e0a..be359af31 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -308,30 +308,6 @@ static void vm_enable_paging(void) write_cr4(cr4); } -/*===========================================================================* - * umap_bios * - *===========================================================================*/ -phys_bytes umap_bios(vir_addr, bytes) -vir_bytes vir_addr; /* virtual address in BIOS segment */ -vir_bytes bytes; /* # of bytes to be copied */ -{ -/* Calculate the physical memory address at the BIOS. Note: currently, BIOS - * address zero (the first BIOS interrupt vector) is not considered as an - * error here, but since the physical address will be zero as well, the - * calling function will think an error occurred. This is not a problem, - * since no one uses the first BIOS interrupt vector. - */ - - /* Check all acceptable ranges. */ - if (vir_addr >= BIOS_MEM_BEGIN && vir_addr + bytes <= BIOS_MEM_END) - return (phys_bytes) vir_addr; - else if (vir_addr >= BASE_MEM_TOP && vir_addr + bytes <= UPPER_MEM_END) - return (phys_bytes) vir_addr; - - printf("Warning, error in umap_bios, virtual address 0x%lx\n", vir_addr); - return 0; -} - /*===========================================================================* * umap_local * *===========================================================================*/ @@ -737,9 +713,7 @@ 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. - * Virtual addresses can be in ABS, LOCAL_SEG, or BIOS_SEG. - */ +/* Copy bytes from virtual address src_addr to virtual address dst_addr. */ struct vir_addr *vir_addr[2]; /* virtual source and destination address */ phys_bytes phys_addr[2]; /* absolute source and destination */ int seg_index; @@ -760,8 +734,7 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */ struct proc *p; type = vir_addr[i]->segment & SEGMENT_TYPE; - if((type != PHYS_SEG && type != BIOS_SEG) && - isokendpt(vir_addr[i]->proc_nr_e, &proc_nr)) + if((type != PHYS_SEG) && isokendpt(vir_addr[i]->proc_nr_e, &proc_nr)) p = proc_addr(proc_nr); else p = NULL; @@ -789,11 +762,6 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */ bytes, i); } break; -#if _MINIX_CHIP == _CHIP_INTEL - case BIOS_SEG: - phys_addr[i] = umap_bios(vir_addr[i]->offset, bytes ); - break; -#endif case PHYS_SEG: phys_addr[i] = vir_addr[i]->offset; break; @@ -917,25 +885,6 @@ void arch_pre_exec(struct proc *pr, const u32_t ip, const u32_t sp) pr->p_reg.sp = sp; } -/*===========================================================================* - * arch_umap * - *===========================================================================*/ -int arch_umap(const struct proc *pr, vir_bytes offset, vir_bytes count, - int seg, phys_bytes *addr) -{ - switch(seg) { - case BIOS_SEG: - *addr = umap_bios(offset, count); - return OK; - } - - /* This must be EINVAL; the umap fallback function in - * lib/syslib/alloc_util.c depends on it to detect an - * older kernel (as opposed to mapping error). - */ - return EINVAL; -} - /* VM reports page directory slot we're allowed to use freely. */ void i386_freepde(const int pde) { diff --git a/kernel/proto.h b/kernel/proto.h index 4a61bbb0b..3eaf28e7a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -169,7 +169,6 @@ int data_copy_vmcheck(struct proc *, endpoint_t from, vir_bytes from_addr, endpoint_t to, vir_bytes to_addr, size_t bytes); void alloc_segments(struct proc *rp); void vm_stop(void); -phys_bytes umap_bios(vir_bytes vir_addr, vir_bytes bytes); phys_bytes umap_local(register struct proc *rp, int seg, vir_bytes vir_addr, vir_bytes bytes); phys_bytes umap_virtual(struct proc* rp, int seg, vir_bytes vir_addr, @@ -195,8 +194,6 @@ void do_ser_debug(void); int arch_get_params(char *parm, int max); int arch_set_params(char *parm, int max); void arch_pre_exec(struct proc *pr, u32_t, u32_t); -int arch_umap(const struct proc *pr, vir_bytes, vir_bytes, int, - phys_bytes *); int arch_do_vmctl(message *m_ptr, struct proc *p); int vm_contiguous(const struct proc *targetproc, vir_bytes vir_buf, size_t count); diff --git a/kernel/system/do_umap_remote.c b/kernel/system/do_umap_remote.c index efebb4652..5a62d2102 100644 --- a/kernel/system/do_umap_remote.c +++ b/kernel/system/do_umap_remote.c @@ -32,7 +32,7 @@ int do_umap_remote(struct proc * caller, message * m_ptr) int 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, r; + int proc_nr, proc_nr_grantee; int naughty = 0; phys_bytes phys_addr = 0, lin_addr = 0; struct proc *targetpr; @@ -105,10 +105,8 @@ int do_umap_remote(struct proc * caller, message * m_ptr) panic("vm_lookup returned zero physical address"); break; default: - if((r=arch_umap(targetpr, offset, count, seg_type, &lin_addr)) - != OK) - return r; - phys_addr = lin_addr; + printf("umap: peculiar type\n"); + return EINVAL; } if(vm_running && vm_lookup_range(targetpr, lin_addr, NULL, count) != count) {