Remote unused segctl kernel call

This commit is contained in:
Erik van der Kouwe 2011-04-26 23:28:23 +02:00
parent 7db58ddc19
commit e969b5e11b
21 changed files with 5 additions and 179 deletions

View file

@ -1150,7 +1150,6 @@ struct
{ "PRIVCTL", SYS_PRIVCTL }, { "PRIVCTL", SYS_PRIVCTL },
{ "TRACE", SYS_TRACE }, { "TRACE", SYS_TRACE },
{ "KILL", SYS_KILL }, { "KILL", SYS_KILL },
{ "SEGCTL", SYS_SEGCTL },
{ "UMAP", SYS_UMAP }, { "UMAP", SYS_UMAP },
{ "VIRCOPY", SYS_VIRCOPY }, { "VIRCOPY", SYS_VIRCOPY },
{ "PHYSCOPY", SYS_PHYSCOPY }, { "PHYSCOPY", SYS_PHYSCOPY },

View file

@ -16,12 +16,11 @@ struct segdesc_s { /* segment descriptor for protected mode */
u8_t base_high; u8_t base_high;
}; };
#define LDT_SIZE (2 + NR_REMOTE_SEGS) /* CS, DS and remote segments */ #define LDT_SIZE 2 /* CS and DS */
/* Fixed local descriptors. */ /* Fixed local descriptors. */
#define CS_LDT_INDEX 0 /* process CS */ #define CS_LDT_INDEX 0 /* process CS */
#define DS_LDT_INDEX 1 /* process DS=ES=FS=GS=SS */ #define DS_LDT_INDEX 1 /* process DS=ES=FS=GS=SS */
#define EXTRA_LDT_INDEX 2 /* first of the extra LDT entries */
typedef struct segframe { typedef struct segframe {
reg_t p_ldt_sel; /* selector in gdt with ldt base and limit */ reg_t p_ldt_sel; /* selector in gdt with ldt base and limit */

View file

@ -329,7 +329,6 @@
# define SYS_SIGRETURN (KERNEL_CALL + 10) /* sys_sigreturn() */ # define SYS_SIGRETURN (KERNEL_CALL + 10) /* sys_sigreturn() */
# define SYS_NEWMAP (KERNEL_CALL + 11) /* sys_newmap() */ # define SYS_NEWMAP (KERNEL_CALL + 11) /* sys_newmap() */
# define SYS_SEGCTL (KERNEL_CALL + 12) /* sys_segctl() */
# define SYS_MEMSET (KERNEL_CALL + 13) /* sys_memset() */ # define SYS_MEMSET (KERNEL_CALL + 13) /* sys_memset() */
# define SYS_UMAP (KERNEL_CALL + 14) /* sys_umap() */ # define SYS_UMAP (KERNEL_CALL + 14) /* sys_umap() */
@ -441,13 +440,6 @@
# define IRQ_LONG 0x400 /* long values */ # define IRQ_LONG 0x400 /* long values */
#define IRQ_HOOK_ID m5_l3 /* id of irq hook at kernel */ #define IRQ_HOOK_ID m5_l3 /* id of irq hook at kernel */
/* Field names for SYS_SEGCTL. */
#define SEG_SELECT m4_l1 /* segment selector returned */
#define SEG_OFFSET m4_l2 /* offset in segment returned */
#define SEG_PHYS m4_l3 /* physical address of segment */
#define SEG_SIZE m4_l4 /* segment size */
#define SEG_INDEX m4_l5 /* segment index in remote map */
/* Field names for SYS_ABORT. */ /* Field names for SYS_ABORT. */
#define ABRT_HOW m1_i1 /* RBT_REBOOT, RBT_HALT, etc. */ #define ABRT_HOW m1_i1 /* RBT_REBOOT, RBT_HALT, etc. */
#define ABRT_MON_ENDPT m1_i2 /* process where monitor params are */ #define ABRT_MON_ENDPT m1_i2 /* process where monitor params are */

View file

@ -63,11 +63,7 @@
#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 REMOTE_SEG 0x0100 /* flags indicating remote memory segment */
#define NR_REMOTE_SEGS 3 /* # remote memory regions (variable) */
#define BIOS_SEG 0x0200 /* flags indicating BIOS memory segment */ #define BIOS_SEG 0x0200 /* flags indicating BIOS memory segment */
#define NR_BIOS_SEGS 3 /* # BIOS memory regions (variable) */
#define PHYS_SEG 0x0400 /* flag indicating entire physical memory */ #define PHYS_SEG 0x0400 /* flag indicating entire physical memory */

View file

@ -175,8 +175,6 @@ _PROTOTYPE(int sys_umap, (endpoint_t proc_ep, int seg, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr)); vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_umap_data_fb, (endpoint_t proc_ep, vir_bytes vir_addr, _PROTOTYPE(int sys_umap_data_fb, (endpoint_t proc_ep, vir_bytes vir_addr,
vir_bytes bytes, phys_bytes *phys_addr)); vir_bytes bytes, phys_bytes *phys_addr));
_PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off,
phys_bytes phys, vir_bytes size));
/* Shorthands for sys_getinfo() system call. */ /* Shorthands for sys_getinfo() system call. */
#define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0) #define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0)

View file

@ -152,7 +152,6 @@ service tty
ipc ALL_SYS; # All system ipc targets allowed ipc ALL_SYS; # All system ipc targets allowed
system # Extra kernel calls allowed: system # Extra kernel calls allowed:
KILL # 06 KILL # 06
SEGCTL # 12
UMAP # 14 UMAP # 14
VIRCOPY # 15 VIRCOPY # 15
PHYSCOPY # 16 PHYSCOPY # 16
@ -179,7 +178,6 @@ service memory
uid 0; uid 0;
ipc ALL_SYS; # All system ipc targets allowed ipc ALL_SYS; # All system ipc targets allowed
system # Extra kernel calls allowed: system # Extra kernel calls allowed:
SEGCTL # 12
UMAP # 14 UMAP # 14
VIRCOPY # 15 VIRCOPY # 15
PHYSCOPY # 16 PHYSCOPY # 16
@ -204,7 +202,6 @@ service log
uid 0; uid 0;
ipc ALL_SYS; # All system ipc targets allowed ipc ALL_SYS; # All system ipc targets allowed
system # Extra kernel calls allowed: system # Extra kernel calls allowed:
SEGCTL # 12
UMAP # 14 UMAP # 14
VIRCOPY # 15 VIRCOPY # 15
IRQCTL # 19 IRQCTL # 19

View file

@ -5,8 +5,6 @@
#include <machine/interrupt.h> #include <machine/interrupt.h>
#include <machine/memory.h> #include <machine/memory.h>
#define NR_REMOTE_SEGS 3 /* # remote memory regions (variable) */
/* Constants for protected mode. */ /* Constants for protected mode. */
/* Table sizes. */ /* Table sizes. */

View file

@ -299,51 +299,6 @@ PRIVATE void vm_enable_paging(void)
write_cr4(cr4); 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 * * umap_local *
*===========================================================================*/ *===========================================================================*/
@ -729,7 +684,7 @@ 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, 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 */ 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 */
@ -780,13 +735,6 @@ int vmcheck; /* if nonzero, can return VMSUSPEND */
bytes, i); bytes, i);
} }
break; 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 #if _MINIX_CHIP == _CHIP_INTEL
case BIOS_SEG: case BIOS_SEG:
phys_addr[i] = umap_bios(vir_addr[i]->offset, bytes ); 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) 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. */ /* 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));
pr->p_reg.pc = ip; pr->p_reg.pc = ip;
pr->p_reg.sp = sp; pr->p_reg.sp = sp;
} }

View file

@ -35,7 +35,6 @@
#define USE_VDEVIO 1 /* process vector with I/O requests */ #define USE_VDEVIO 1 /* process vector with I/O requests */
#define USE_SDEVIO 1 /* perform I/O request on a buffer */ #define USE_SDEVIO 1 /* perform I/O request on a buffer */
#define USE_IRQCTL 1 /* set an interrupt policy */ #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_PRIVCTL 1 /* system privileges control */
#define USE_UMAP 1 /* map virtual to physical address */ #define USE_UMAP 1 /* map virtual to physical address */
#define USE_VIRCOPY 1 /* copy using virtual addressing */ #define USE_VIRCOPY 1 /* copy using virtual addressing */

View file

@ -43,7 +43,6 @@ struct priv {
sigset_t s_sig_pending; /* pending signals */ sigset_t s_sig_pending; /* pending signals */
timer_t s_alarm_timer; /* synchronous alarm timer */ 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 */ reg_t *s_stack_guard; /* stack guard word for kernel tasks */
int s_nr_io_range; /* allowed I/O ports */ int s_nr_io_range; /* allowed I/O ports */

View file

@ -176,15 +176,11 @@ _PROTOTYPE( void alloc_segments, (struct proc *rp) );
_PROTOTYPE( void vm_stop, (void) ); _PROTOTYPE( void vm_stop, (void) );
_PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg, _PROTOTYPE( phys_bytes umap_local, (register struct proc *rp, int seg,
vir_bytes vir_addr, vir_bytes bytes)); 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, _PROTOTYPE( phys_bytes umap_virtual, (struct proc* rp,
int seg, vir_bytes vir_addr, vir_bytes bytes) ); int seg, vir_bytes vir_addr, vir_bytes bytes) );
_PROTOTYPE( phys_bytes seg2phys, (u16_t) ); _PROTOTYPE( phys_bytes seg2phys, (u16_t) );
_PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern, _PROTOTYPE( int vm_phys_memset, (phys_bytes source, u8_t pattern,
phys_bytes count) ); 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( int intr_init, (int, int) );
_PROTOTYPE( void halt_cpu, (void) ); _PROTOTYPE( void halt_cpu, (void) );
_PROTOTYPE( void arch_init, (void) ); _PROTOTYPE( void arch_init, (void) );

View file

@ -216,7 +216,6 @@ PUBLIC void system_init(void)
/* Memory management. */ /* Memory management. */
map(SYS_NEWMAP, do_newmap); /* set up a process memory map */ 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_MEMSET, do_memset); /* write char to memory area */
map(SYS_VMCTL, do_vmctl); /* various VM process settings */ map(SYS_VMCTL, do_vmctl); /* various VM process settings */

View file

@ -107,11 +107,6 @@ _PROTOTYPE( int do_privctl, (struct proc * caller, message *m_ptr) );
#define do_privctl NULL #define do_privctl NULL
#endif #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) ); _PROTOTYPE( int do_irqctl, (struct proc * caller, message *m_ptr) );
#if ! USE_IRQCTL #if ! USE_IRQCTL
#define do_irqctl NULL #define do_irqctl NULL

View file

@ -23,7 +23,6 @@ SRCS+= \
do_memset.c \ do_memset.c \
do_setgrant.c \ do_setgrant.c \
do_privctl.c \ do_privctl.c \
do_segctl.c \
do_safecopy.c \ do_safecopy.c \
do_safemap.c \ do_safemap.c \
do_sysctl.c \ do_sysctl.c \

View file

@ -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 */

View file

@ -46,11 +46,6 @@ PUBLIC int do_umap(struct proc * caller, message * m_ptr)
if(!lin_addr) return EFAULT; if(!lin_addr) return EFAULT;
naughty = 1; naughty = 1;
break; 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: case LOCAL_VM_SEG:
if(seg_index == MEM_GRANT) { if(seg_index == MEM_GRANT) {
vir_bytes newoffset; vir_bytes newoffset;

View file

@ -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_int_pending = from_privp->s_int_pending;
privp->s_sig_pending = from_privp->s_sig_pending; privp->s_sig_pending = from_privp->s_sig_pending;
privp->s_alarm_timer = from_privp->s_alarm_timer; privp->s_alarm_timer = from_privp->s_alarm_timer;
memcpy(privp->s_farmem, from_privp->s_farmem, sizeof(privp->s_farmem));
} }
/*===========================================================================* /*===========================================================================*

View file

@ -86,7 +86,6 @@ SRCS= \
sys_schedctl.c \ sys_schedctl.c \
sys_schedule.c \ sys_schedule.c \
sys_sdevio.c \ sys_sdevio.c \
sys_segctl.c \
sys_setalarm.c \ sys_setalarm.c \
sys_setgrant.c \ sys_setgrant.c \
sys_sigreturn.c \ sys_sigreturn.c \

View file

@ -12,7 +12,7 @@ phys_bytes bytes; /* how many bytes */
{ {
/* Transfer a block of data. The source and destination can each either be a /* Transfer a block of data. The source and destination can each either be a
* process number or SELF (to indicate own process number). Virtual addresses * process number or SELF (to indicate own process number). Virtual addresses
* are offsets within LOCAL_SEG (text, stack, data), REMOTE_SEG, or BIOS_SEG. * are offsets within LOCAL_SEG (text, stack, data), or BIOS_SEG.
* Physicall addressing is also possible with PHYS_SEG. * Physicall addressing is also possible with PHYS_SEG.
*/ */

View file

@ -1,24 +0,0 @@
#include "syslib.h"
/*===========================================================================*
* sys_segctl *
*===========================================================================*/
PUBLIC int sys_segctl(index, seg, off, phys, size)
int *index; /* return index of remote segment */
u16_t *seg; /* return segment selector here */
vir_bytes *off; /* return offset in segment here */
phys_bytes phys; /* physical address to convert */
vir_bytes size; /* size of segment */
{
message m;
int s;
m.SEG_PHYS = phys;
m.SEG_SIZE = size;
s = _kernel_call(SYS_SEGCTL, &m);
*index = (int) m.SEG_INDEX;
*seg = (u16_t) m.SEG_SELECT;
*off = (vir_bytes) m.SEG_OFFSET;
return s;
}

View file

@ -12,7 +12,7 @@ phys_bytes bytes; /* how many bytes */
{ {
/* Transfer a block of data. The source and destination can each either be a /* Transfer a block of data. The source and destination can each either be a
* process number or SELF (to indicate own process number). Virtual addresses * process number or SELF (to indicate own process number). Virtual addresses
* are offsets within LOCAL_SEG (text, stack, data), REMOTE_SEG, or BIOS_SEG. * are offsets within LOCAL_SEG (text, stack, data), or BIOS_SEG.
*/ */
message copy_mess; message copy_mess;