Remote unused segctl kernel call
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
#include <machine/interrupt.h>
|
||||
#include <machine/memory.h>
|
||||
|
||||
#define NR_REMOTE_SEGS 3 /* # remote memory regions (variable) */
|
||||
|
||||
/* Constants for protected mode. */
|
||||
|
||||
/* Table sizes. */
|
||||
|
||||
@@ -299,51 +299,6 @@ PRIVATE void vm_enable_paging(void)
|
||||
write_cr4(cr4);
|
||||
}
|
||||
|
||||
PUBLIC vir_bytes alloc_remote_segment(u32_t *selector,
|
||||
segframe_t *segments, const int index, phys_bytes phys,
|
||||
vir_bytes size, int priv)
|
||||
{
|
||||
phys_bytes offset = 0;
|
||||
/* Check if the segment size can be recorded in bytes, that is, check
|
||||
* if descriptor's limit field can delimited the allowed memory region
|
||||
* precisely. This works up to 1MB. If the size is larger, 4K pages
|
||||
* instead of bytes are used.
|
||||
*/
|
||||
if (size < BYTE_GRAN_MAX) {
|
||||
init_dataseg(&segments->p_ldt[EXTRA_LDT_INDEX+index],
|
||||
phys, size, priv);
|
||||
*selector = ((EXTRA_LDT_INDEX+index)*0x08) | (1*0x04) | priv;
|
||||
offset = 0;
|
||||
} else {
|
||||
init_dataseg(&segments->p_ldt[EXTRA_LDT_INDEX+index],
|
||||
phys & ~0xFFFF, 0, priv);
|
||||
*selector = ((EXTRA_LDT_INDEX+index)*0x08) | (1*0x04) | priv;
|
||||
offset = phys & 0xFFFF;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
PUBLIC phys_bytes umap_remote(const struct proc* rp, const int seg,
|
||||
const vir_bytes vir_addr, const vir_bytes bytes)
|
||||
{
|
||||
/* Calculate the physical memory address for a given virtual address. */
|
||||
struct far_mem *fm;
|
||||
|
||||
#if 0
|
||||
if(rp->p_misc_flags & MF_FULLVM) return 0;
|
||||
#endif
|
||||
|
||||
if (bytes <= 0) return( (phys_bytes) 0);
|
||||
if (seg < 0 || seg >= NR_REMOTE_SEGS) return( (phys_bytes) 0);
|
||||
|
||||
fm = &rp->p_priv->s_farmem[seg];
|
||||
if (! fm->in_use) return( (phys_bytes) 0);
|
||||
if (vir_addr + bytes > fm->mem_len) return( (phys_bytes) 0);
|
||||
|
||||
return(fm->mem_phys + (phys_bytes) vir_addr);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* umap_local *
|
||||
*===========================================================================*/
|
||||
@@ -729,7 +684,7 @@ 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, REMOTE_SEG, or BIOS_SEG.
|
||||
* Virtual addresses can be in ABS, LOCAL_SEG, or BIOS_SEG.
|
||||
*/
|
||||
struct vir_addr *vir_addr[2]; /* virtual source and destination address */
|
||||
phys_bytes phys_addr[2]; /* absolute source and destination */
|
||||
@@ -780,13 +735,6 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
|
||||
bytes, i);
|
||||
}
|
||||
break;
|
||||
case REMOTE_SEG:
|
||||
if(!p) {
|
||||
return EDEADSRCDST;
|
||||
}
|
||||
seg_index = vir_addr[i]->segment & SEGMENT_INDEX;
|
||||
phys_addr[i] = umap_remote(p, seg_index, vir_addr[i]->offset, bytes);
|
||||
break;
|
||||
#if _MINIX_CHIP == _CHIP_INTEL
|
||||
case BIOS_SEG:
|
||||
phys_addr[i] = umap_bios(vir_addr[i]->offset, bytes );
|
||||
@@ -910,9 +858,7 @@ PUBLIC int data_copy_vmcheck(struct proc * caller,
|
||||
*===========================================================================*/
|
||||
PUBLIC void arch_pre_exec(struct proc *pr, const u32_t ip, const u32_t sp)
|
||||
{
|
||||
/* wipe extra LDT entries, set program counter, and stack pointer. */
|
||||
memset(pr->p_seg.p_ldt + EXTRA_LDT_INDEX, 0,
|
||||
sizeof(pr->p_seg.p_ldt[0]) * (LDT_SIZE - EXTRA_LDT_INDEX));
|
||||
/* set program counter and stack pointer. */
|
||||
pr->p_reg.pc = ip;
|
||||
pr->p_reg.sp = sp;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#define USE_VDEVIO 1 /* process vector with I/O requests */
|
||||
#define USE_SDEVIO 1 /* perform I/O request on a buffer */
|
||||
#define USE_IRQCTL 1 /* set an interrupt policy */
|
||||
#define USE_SEGCTL 1 /* set up a remote segment */
|
||||
#define USE_PRIVCTL 1 /* system privileges control */
|
||||
#define USE_UMAP 1 /* map virtual to physical address */
|
||||
#define USE_VIRCOPY 1 /* copy using virtual addressing */
|
||||
|
||||
@@ -43,7 +43,6 @@ struct priv {
|
||||
sigset_t s_sig_pending; /* pending signals */
|
||||
|
||||
timer_t s_alarm_timer; /* synchronous alarm timer */
|
||||
struct far_mem s_farmem[NR_REMOTE_SEGS]; /* remote memory map */
|
||||
reg_t *s_stack_guard; /* stack guard word for kernel tasks */
|
||||
|
||||
int s_nr_io_range; /* allowed I/O ports */
|
||||
|
||||
@@ -176,15 +176,11 @@ _PROTOTYPE( void alloc_segments, (struct proc *rp) );
|
||||
_PROTOTYPE( void vm_stop, (void) );
|
||||
_PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg,
|
||||
vir_bytes vir_addr, vir_bytes bytes));
|
||||
_PROTOTYPE( phys_bytes umap_remote, (const struct proc* rp, int seg,
|
||||
vir_bytes vir_addr, vir_bytes bytes) );
|
||||
_PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
|
||||
int seg, vir_bytes vir_addr, vir_bytes bytes) );
|
||||
_PROTOTYPE( phys_bytes seg2phys, (u16_t) );
|
||||
_PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern,
|
||||
phys_bytes count) );
|
||||
_PROTOTYPE( vir_bytes alloc_remote_segment, (u32_t *, segframe_t *,
|
||||
int, phys_bytes, vir_bytes, int));
|
||||
_PROTOTYPE( int intr_init, (int, int) );
|
||||
_PROTOTYPE( void halt_cpu, (void) );
|
||||
_PROTOTYPE( void arch_init, (void) );
|
||||
|
||||
@@ -216,7 +216,6 @@ PUBLIC void system_init(void)
|
||||
|
||||
/* Memory management. */
|
||||
map(SYS_NEWMAP, do_newmap); /* set up a process memory map */
|
||||
map(SYS_SEGCTL, do_segctl); /* add segment and get selector */
|
||||
map(SYS_MEMSET, do_memset); /* write char to memory area */
|
||||
map(SYS_VMCTL, do_vmctl); /* various VM process settings */
|
||||
|
||||
|
||||
@@ -107,11 +107,6 @@ _PROTOTYPE( int do_privctl, (struct proc * caller, message *m_ptr) );
|
||||
#define do_privctl NULL
|
||||
#endif
|
||||
|
||||
_PROTOTYPE( int do_segctl, (struct proc * caller, message *m_ptr) );
|
||||
#if ! USE_SEGCTL
|
||||
#define do_segctl NULL
|
||||
#endif
|
||||
|
||||
_PROTOTYPE( int do_irqctl, (struct proc * caller, message *m_ptr) );
|
||||
#if ! USE_IRQCTL
|
||||
#define do_irqctl NULL
|
||||
|
||||
@@ -23,7 +23,6 @@ SRCS+= \
|
||||
do_memset.c \
|
||||
do_setgrant.c \
|
||||
do_privctl.c \
|
||||
do_segctl.c \
|
||||
do_safecopy.c \
|
||||
do_safemap.c \
|
||||
do_sysctl.c \
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/* The kernel call implemented in this file:
|
||||
* m_type: SYS_SEGCTL
|
||||
*
|
||||
* The parameters for this kernel call are:
|
||||
* m4_l3: SEG_PHYS (physical base address)
|
||||
* m4_l4: SEG_SIZE (size of segment)
|
||||
* m4_l1: SEG_SELECT (return segment selector here)
|
||||
* m4_l2: SEG_OFFSET (return offset within segment here)
|
||||
* m4_l5: SEG_INDEX (return index into remote memory map here)
|
||||
*/
|
||||
#include "kernel/system.h"
|
||||
|
||||
#if USE_SEGCTL
|
||||
|
||||
/*===========================================================================*
|
||||
* do_segctl *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_segctl(struct proc * caller, message * m_ptr)
|
||||
{
|
||||
/* 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.
|
||||
*/
|
||||
u32_t selector;
|
||||
vir_bytes offset;
|
||||
int i, index;
|
||||
phys_bytes phys = (phys_bytes) m_ptr->SEG_PHYS;
|
||||
vir_bytes size = (vir_bytes) m_ptr->SEG_SIZE;
|
||||
int result;
|
||||
|
||||
/* First check if there is a slot available for this segment. */
|
||||
index = -1;
|
||||
for (i=0; i < NR_REMOTE_SEGS; i++) {
|
||||
if (! caller->p_priv->s_farmem[i].in_use) {
|
||||
index = i;
|
||||
caller->p_priv->s_farmem[i].in_use = TRUE;
|
||||
caller->p_priv->s_farmem[i].mem_phys = phys;
|
||||
caller->p_priv->s_farmem[i].mem_len = size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < 0) return(ENOSPC);
|
||||
|
||||
offset = alloc_remote_segment(&selector, &caller->p_seg,
|
||||
i, phys, size, USER_PRIVILEGE);
|
||||
result = OK;
|
||||
|
||||
/* Request successfully done. Now return the result. */
|
||||
m_ptr->SEG_INDEX = index | REMOTE_SEG;
|
||||
m_ptr->SEG_SELECT = selector;
|
||||
m_ptr->SEG_OFFSET = offset;
|
||||
return(result);
|
||||
}
|
||||
|
||||
#endif /* USE_SEGCTL */
|
||||
|
||||
@@ -46,11 +46,6 @@ PUBLIC int do_umap(struct proc * caller, message * m_ptr)
|
||||
if(!lin_addr) return EFAULT;
|
||||
naughty = 1;
|
||||
break;
|
||||
case REMOTE_SEG:
|
||||
phys_addr = lin_addr = umap_remote(targetpr, seg_index, offset, count);
|
||||
if(!lin_addr) return EFAULT;
|
||||
naughty = 1;
|
||||
break;
|
||||
case LOCAL_VM_SEG:
|
||||
if(seg_index == MEM_GRANT) {
|
||||
vir_bytes newoffset;
|
||||
|
||||
@@ -152,7 +152,6 @@ PRIVATE void adjust_priv_slot(struct priv *privp, struct priv *from_privp)
|
||||
privp->s_int_pending = from_privp->s_int_pending;
|
||||
privp->s_sig_pending = from_privp->s_sig_pending;
|
||||
privp->s_alarm_timer = from_privp->s_alarm_timer;
|
||||
memcpy(privp->s_farmem, from_privp->s_farmem, sizeof(privp->s_farmem));
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
||||
Reference in New Issue
Block a user