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
This commit is contained in:
Ben Gras 2012-05-09 18:34:40 +02:00
parent b611e4c226
commit cfb2d7bca5
10 changed files with 23 additions and 80 deletions

View File

@ -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) static void do_first_init(dpeth_t *dep, const dp_conf_t *dcp)
{ {
if (dep->de_linmem != 0) { dep->de_linmem = 0xFFFF0000;
dep->de_memsegm = BIOS_SEG;
/* phys2seg(&dep->de_memsegm, &dep->de_memoffs, dep->de_linmem); */
} else
dep->de_linmem = 0xFFFF0000;
/* Make sure statisics are cleared */ /* Make sure statisics are cleared */
memset((void *) &(dep->de_stat), 0, sizeof(eth_stat_t)); memset((void *) &(dep->de_stat), 0, sizeof(eth_stat_t));

View File

@ -117,7 +117,6 @@ typedef struct dpeth {
#define DEI_DEFAULT 0x8000 #define DEI_DEFAULT 0x8000
phys_bytes de_linmem; /* For boards using shared memory */ phys_bytes de_linmem; /* For boards using shared memory */
unsigned short de_memsegm;
vir_bytes de_memoffs; vir_bytes de_memoffs;
int de_ramsize; /* Size of on board memory */ int de_ramsize; /* Size of on board memory */
int de_offset_page; /* Offset of shared memory page */ int de_offset_page; /* Offset of shared memory page */

View File

@ -366,9 +366,8 @@ static int do_probe(void)
/* See if there is a printer at all. */ /* See if there is a printer at all. */
/* Get the base port for first printer. */ /* Get the base port for first printer. */
if(sys_vircopy(SELF, BIOS_SEG, LPT1_IO_PORT_ADDR, if(sys_readbios(LPT1_IO_PORT_ADDR, &port_base, LPT1_IO_PORT_SIZE) != OK) {
SELF, D, (vir_bytes) &port_base, LPT1_IO_PORT_SIZE) != OK) { panic("do_initialize: sys_readbios failed");
panic("do_initialize: sys_vircopy failed");
} }
/* If the port is zero, the parallel port is not available at all. */ /* If the port is zero, the parallel port is not available at all. */

View File

@ -417,10 +417,10 @@ service printer
system system
KILL # 6 KILL # 6
UMAP # 14 UMAP # 14
VIRCOPY # 15
IRQCTL # 19 IRQCTL # 19
DEVIO # 21 DEVIO # 21
VDEVIO # 23 VDEVIO # 23
READBIOS # 35
; ;
}; };

View File

@ -63,8 +63,6 @@
#define D 1 /* proc[i].mem_map[D] is for data */ #define D 1 /* proc[i].mem_map[D] is for data */
#define S 2 /* proc[i].mem_map[S] is for stack */ #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 PHYS_SEG 0x0400 /* flag indicating entire physical memory */
#define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */ #define LOCAL_VM_SEG 0x1000 /* same as LOCAL_SEG, but with vm lookup */

View File

@ -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); int sys_irqctl(int request, int irq_vec, int policy, int *irq_hook_id);
/* Shorthands for sys_vircopy() and sys_physcopy() system calls. */ /* 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) \ #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) 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) \ #define sys_textcopy(src_proc, src_vir, dst_proc, dst_vir, bytes) \

View File

@ -16,13 +16,24 @@
int do_readbios(struct proc * caller, message * m_ptr) 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;
src.segment = BIOS_SEG; src.segment = PHYS_SEG;
dst.segment = D; dst.segment = D;
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;
src.proc_nr_e = NONE; src.proc_nr_e = NONE;
dst.proc_nr_e = m_ptr->m_source; 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); return virtual_copy_vmcheck(caller, &src, &dst, m_ptr->RDB_SIZE);
} }

View File

@ -308,30 +308,6 @@ static void vm_enable_paging(void)
write_cr4(cr4); 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 * * umap_local *
*===========================================================================*/ *===========================================================================*/
@ -737,9 +713,7 @@ 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. */
* Virtual addresses can be in ABS, LOCAL_SEG, or BIOS_SEG.
*/
struct vir_addr *vir_addr[2]; /* virtual source and destination address */ struct vir_addr *vir_addr[2]; /* virtual source and destination address */
phys_bytes phys_addr[2]; /* absolute source and destination */ phys_bytes phys_addr[2]; /* absolute source and destination */
int seg_index; int seg_index;
@ -760,8 +734,7 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
struct proc *p; struct proc *p;
type = vir_addr[i]->segment & SEGMENT_TYPE; type = vir_addr[i]->segment & SEGMENT_TYPE;
if((type != PHYS_SEG && type != BIOS_SEG) && if((type != PHYS_SEG) && isokendpt(vir_addr[i]->proc_nr_e, &proc_nr))
isokendpt(vir_addr[i]->proc_nr_e, &proc_nr))
p = proc_addr(proc_nr); p = proc_addr(proc_nr);
else else
p = NULL; p = NULL;
@ -789,11 +762,6 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
bytes, i); bytes, i);
} }
break; break;
#if _MINIX_CHIP == _CHIP_INTEL
case BIOS_SEG:
phys_addr[i] = umap_bios(vir_addr[i]->offset, bytes );
break;
#endif
case PHYS_SEG: case PHYS_SEG:
phys_addr[i] = vir_addr[i]->offset; phys_addr[i] = vir_addr[i]->offset;
break; 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; 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. */ /* VM reports page directory slot we're allowed to use freely. */
void i386_freepde(const int pde) void i386_freepde(const int pde)
{ {

View File

@ -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); from_addr, endpoint_t to, vir_bytes to_addr, size_t bytes);
void alloc_segments(struct proc *rp); void alloc_segments(struct proc *rp);
void vm_stop(void); 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 phys_bytes umap_local(register struct proc *rp, int seg, vir_bytes
vir_addr, vir_bytes bytes); vir_addr, vir_bytes bytes);
phys_bytes umap_virtual(struct proc* rp, int seg, vir_bytes vir_addr, 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_get_params(char *parm, int max);
int arch_set_params(char *parm, int max); int arch_set_params(char *parm, int max);
void arch_pre_exec(struct proc *pr, u32_t, u32_t); 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 arch_do_vmctl(message *m_ptr, struct proc *p);
int vm_contiguous(const struct proc *targetproc, vir_bytes vir_buf, int vm_contiguous(const struct proc *targetproc, vir_bytes vir_buf,
size_t count); size_t count);

View File

@ -32,7 +32,7 @@ int do_umap_remote(struct proc * caller, message * m_ptr)
int count = m_ptr->CP_NR_BYTES; int 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, r; int proc_nr, proc_nr_grantee;
int naughty = 0; int naughty = 0;
phys_bytes phys_addr = 0, lin_addr = 0; phys_bytes phys_addr = 0, lin_addr = 0;
struct proc *targetpr; struct proc *targetpr;
@ -105,10 +105,8 @@ int do_umap_remote(struct proc * caller, message * m_ptr)
panic("vm_lookup returned zero physical address"); panic("vm_lookup returned zero physical address");
break; break;
default: default:
if((r=arch_umap(targetpr, offset, count, seg_type, &lin_addr)) printf("umap: peculiar type\n");
!= OK) return EINVAL;
return r;
phys_addr = lin_addr;
} }
if(vm_running && vm_lookup_range(targetpr, lin_addr, NULL, count) != count) { if(vm_running && vm_lookup_range(targetpr, lin_addr, NULL, count) != count) {