Adding ipc_ prefix to ipc primitives
* Also change _orig to _intr for clarity
* Cleaned up {IPC,KER}VEC
* Renamed _minix_kernel_info_struct to get_minix_kerninfo
* Merged _senda.S into _ipc.S
* Moved into separate files get_minix_kerninfo and _do_kernel_call
* Adapted do_kernel_call to follow same _ convention as ipc functions
* Drop patches in libc/net/send.c and libc/include/namespace.h
Change-Id: If4ea21ecb65435170d7d87de6c826328e84c18d0
This commit is contained in:
@@ -11,9 +11,10 @@ ucontext.o: ucontextoffsets.h
|
||||
|
||||
SRCS+= \
|
||||
__sigreturn.S \
|
||||
_do_kernel_call_intr.S \
|
||||
_ipc.S \
|
||||
_senda.S \
|
||||
brksize.S \
|
||||
get_minix_kerninfo.S \
|
||||
ucontext.S
|
||||
|
||||
ucontextoffsets.h: ${CF}
|
||||
|
||||
8
lib/libc/arch/arm/sys-minix/_do_kernel_call_intr.S
Normal file
8
lib/libc/arch/arm/sys-minix/_do_kernel_call_intr.S
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <minix/ipcconst.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(_do_kernel_call_intr)
|
||||
/* r0 already holds msg ptr */
|
||||
mov r3, #KERVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
bx lr
|
||||
@@ -4,80 +4,71 @@
|
||||
/**========================================================================* */
|
||||
/* IPC assembly routines * */
|
||||
/**========================================================================* */
|
||||
ENTRY(_send_orig)
|
||||
ENTRY(_ipc_send_intr)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
mov r2, r1 /* r2 = msg ptr */
|
||||
mov r1, r0 /* r1 = src_dest */
|
||||
mov r0, #SEND /* _send(dest, ptr) */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
mov r0, #SEND /* _ipc_send(dest, ptr) */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
ENTRY(_receive_orig)
|
||||
ENTRY(_ipc_receive_intr)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
push {r2} /* save status ptr */
|
||||
mov r2, r1 /* r2 = msg ptr */
|
||||
mov r1, r0 /* r1 = src_dest */
|
||||
mov r0, #RECEIVE /* _receive(src, ptr) */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
mov r0, #RECEIVE /* _ipc_receive(src, ptr) */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {r2} /* restore status ptr */
|
||||
str r1, [r2]
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
ENTRY(_sendrec_orig)
|
||||
ENTRY(_ipc_sendrec_intr)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
mov r2, r1 /* r2 = msg ptr */
|
||||
mov r1, r0 /* r1 = src_dest */
|
||||
mov r0, #SENDREC /* _sendrec(srcdest, ptr) */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
mov r0, #SENDREC /* _ipc_sendrec(srcdest, ptr) */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
ENTRY(_minix_kernel_info_struct)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
push {r0}
|
||||
mov r1, #0
|
||||
mov r2, #0
|
||||
mov r0, #MINIX_KERNINFO /* kerninfo() */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {r2} /* r2 = return struct ptr (was r0) */
|
||||
str r1, [r2]
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
ENTRY(_notify_orig)
|
||||
ENTRY(_ipc_notify_intr)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
mov r1, r0 /* r1 = src_dest */
|
||||
mov r0, #NOTIFY /* _notify(srcdst) */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
mov r0, #NOTIFY /* _ipc_notify(srcdst) */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
ENTRY(_sendnb_orig)
|
||||
ENTRY(_ipc_sendnb_intr)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
mov r2, r1 /* r2 = msg ptr */
|
||||
mov r1, r0 /* r1 = src_dest */
|
||||
mov r0, #SENDNB /* _sendnb(dest, ptr) */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
mov r0, #SENDNB /* _ipc_sendnb(dest, ptr) */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
|
||||
ENTRY(_do_kernel_call_orig)
|
||||
/* r0 already holds msg ptr */
|
||||
mov r3, #KERVEC /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
ENTRY(_ipc_senda_intr)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
mov r2, r0 /* r2 = table */
|
||||
/* r1 already holds count */
|
||||
mov r0, #SENDA /* _ipc_senda(table, count) */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#include <minix/ipcconst.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(_senda_orig)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
mov r2, r0 /* r2 = table */
|
||||
/* r1 already holds count */
|
||||
mov r0, #SENDA /* _senda(table, count) */
|
||||
mov r3, #IPCVEC /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {fp}
|
||||
bx lr
|
||||
17
lib/libc/arch/arm/sys-minix/get_minix_kerninfo.S
Normal file
17
lib/libc/arch/arm/sys-minix/get_minix_kerninfo.S
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <minix/ipcconst.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(get_minix_kerninfo)
|
||||
push {fp}
|
||||
mov fp, sp
|
||||
push {r0}
|
||||
mov r1, #0
|
||||
mov r2, #0
|
||||
mov r0, #MINIX_KERNINFO /* _get_minix_kerninfo() */
|
||||
mov r3, #IPCVEC_INTR /* r3 determines the SVC type */
|
||||
svc #0 /* trap to kernel */
|
||||
pop {r2} /* r2 = return struct ptr (was r0) */
|
||||
str r1, [r2]
|
||||
pop {fp}
|
||||
bx lr
|
||||
|
||||
@@ -11,9 +11,10 @@ ucontext.o: ucontextoffsets.h
|
||||
|
||||
SRCS+= \
|
||||
__sigreturn.S \
|
||||
_do_kernel_call_intr.S \
|
||||
_ipc.S \
|
||||
_senda.S \
|
||||
brksize.S \
|
||||
get_minix_kerninfo.S \
|
||||
ucontext.S
|
||||
|
||||
ucontextoffsets.h: ${CF}
|
||||
|
||||
8
lib/libc/arch/i386/sys-minix/_do_kernel_call_intr.S
Normal file
8
lib/libc/arch/i386/sys-minix/_do_kernel_call_intr.S
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <minix/ipcconst.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(_do_kernel_call_intr)
|
||||
/* pass the message pointer to kernel in the %eax register */
|
||||
movl 4(%esp), %eax
|
||||
int $KERVEC_INTR
|
||||
ret
|
||||
@@ -5,87 +5,84 @@
|
||||
MESSAGE = 12 /* message pointer */
|
||||
STATUS = 16 /* status pointer */
|
||||
|
||||
/* For _ipc_senda() */
|
||||
MSGTAB = 8 /* message table */
|
||||
TABCOUNT = 12 /* number of entries in message table */
|
||||
|
||||
/**========================================================================* */
|
||||
/* IPC assembly routines * */
|
||||
/**========================================================================* */
|
||||
/* all message passing routines save ebx, but destroy eax and ecx. */
|
||||
ENTRY(_send_orig)
|
||||
ENTRY(_ipc_send_intr)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl SRC_DST(%ebp), %eax /* eax = dest-src */
|
||||
movl MESSAGE(%ebp), %ebx /* ebx = message pointer */
|
||||
movl $SEND, %ecx /* _send(dest, ptr) */
|
||||
int $IPCVEC_ORIG /* trap to the kernel */
|
||||
movl $SEND, %ecx /* _ipc_send(dest, ptr) */
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ENTRY(_receive_orig)
|
||||
ENTRY(_ipc_receive_intr)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl SRC_DST(%ebp), %eax /* eax = dest-src */
|
||||
movl MESSAGE(%ebp), %ebx /* ebx = message pointer */
|
||||
movl $RECEIVE, %ecx /* _receive(src, ptr) */
|
||||
int $IPCVEC_ORIG /* trap to the kernel */
|
||||
movl $RECEIVE, %ecx /* _ipc_receive(src, ptr) */
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
movl STATUS(%ebp), %ecx /* ecx = status pointer */
|
||||
movl %ebx, (%ecx)
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ENTRY(_sendrec_orig)
|
||||
ENTRY(_ipc_sendrec_intr)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl SRC_DST(%ebp), %eax /* eax = dest-src */
|
||||
movl MESSAGE(%ebp), %ebx /* ebx = message pointer */
|
||||
movl $SENDREC, %ecx /* _sendrec(srcdest, ptr) */
|
||||
int $IPCVEC_ORIG /* trap to the kernel */
|
||||
movl $SENDREC, %ecx /* _ipc_sendrec(srcdest, ptr) */
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ENTRY(_minix_kernel_info_struct)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl $0, %eax
|
||||
movl $0, %ebx
|
||||
movl $MINIX_KERNINFO, %ecx
|
||||
int $IPCVEC_ORIG /* trap to the kernel */
|
||||
movl 8(%ebp), %ecx /* ecx = return struct ptr */
|
||||
movl %ebx, (%ecx)
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ENTRY(_notify_orig)
|
||||
ENTRY(_ipc_notify_intr)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl SRC_DST(%ebp), %eax /* eax = destination */
|
||||
movl $NOTIFY, %ecx /* _notify(srcdst) */
|
||||
int $IPCVEC_ORIG /* trap to the kernel */
|
||||
movl $NOTIFY, %ecx /* _ipc_notify(srcdst) */
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ENTRY(_sendnb_orig)
|
||||
ENTRY(_ipc_sendnb_intr)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl SRC_DST(%ebp), %eax /* eax = dest-src */
|
||||
movl MESSAGE(%ebp), %ebx /* ebx = message pointer */
|
||||
movl $SENDNB, %ecx /* _sendnb(dest, ptr) */
|
||||
int $IPCVEC_ORIG /* trap to the kernel */
|
||||
movl $SENDNB, %ecx /* _ipc_sendnb(dest, ptr) */
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
ENTRY(_do_kernel_call_orig)
|
||||
/* pass the message pointer to kernel in the %eax register */
|
||||
movl 4(%esp), %eax
|
||||
int $KERVEC_ORIG
|
||||
ENTRY(_ipc_senda_intr)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl TABCOUNT(%ebp), %eax /* eax = count */
|
||||
movl MSGTAB(%ebp), %ebx /* ebx = table */
|
||||
movl $SENDA, %ecx /* _ipc_senda(table, count) */
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#include <minix/ipcconst.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
MSGTAB = 8 /* message table */
|
||||
TABCOUNT = 12 /* number of entries in message table */
|
||||
|
||||
ENTRY(_senda_orig)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl TABCOUNT(%ebp), %eax /* eax = count */
|
||||
movl MSGTAB(%ebp), %ebx /* ebx = table */
|
||||
movl $SENDA, %ecx /* _senda(table, count) */
|
||||
int $IPCVEC /* trap to the kernel */
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
17
lib/libc/arch/i386/sys-minix/get_minix_kerninfo.S
Normal file
17
lib/libc/arch/i386/sys-minix/get_minix_kerninfo.S
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <minix/ipcconst.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(get_minix_kerninfo)
|
||||
push %ebp
|
||||
movl %esp, %ebp
|
||||
push %ebx
|
||||
movl $0, %eax
|
||||
movl $0, %ebx
|
||||
movl $MINIX_KERNINFO, %ecx
|
||||
int $IPCVEC_INTR /* trap to the kernel */
|
||||
movl 8(%ebp), %ecx /* ecx = return struct ptr */
|
||||
movl %ebx, (%ecx)
|
||||
pop %ebx
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
@@ -545,13 +545,7 @@
|
||||
#define seed48 _seed48
|
||||
#define seekdir _seekdir
|
||||
#define select _select
|
||||
#ifdef __minix
|
||||
/* '_send' unfortunately collides with Minix IPC's _send function.
|
||||
* This solution is fragile, a proper renaming of Minix IPCs should
|
||||
* be done insted. */
|
||||
#else /* !__minix */
|
||||
#define send _send
|
||||
#endif /* !__minix */
|
||||
#define setdomainname _setdomainname
|
||||
#define setenv _setenv
|
||||
#define setfsent _setfsent
|
||||
|
||||
@@ -44,15 +44,9 @@ __RCSID("$NetBSD: send.c,v 1.10 2012/03/20 17:44:18 matt Exp $");
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __minix
|
||||
/* UGLY: name clash with minix ipc.
|
||||
* Better solution: redefine minix ipc.
|
||||
*/
|
||||
#else /* !__minix */
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(send, _send)
|
||||
#endif
|
||||
#endif /* !__minix */
|
||||
|
||||
ssize_t
|
||||
send(int s, const void *msg, size_t len, int flags)
|
||||
|
||||
@@ -8,23 +8,26 @@ struct minix_kerninfo *_minix_kerninfo = NULL;
|
||||
void __minix_init(void) __attribute__((__constructor__, __used__));
|
||||
|
||||
struct minix_ipcvecs _minix_ipcvecs = {
|
||||
.sendrec = _sendrec_orig,
|
||||
.send = _send_orig,
|
||||
.notify = _notify_orig,
|
||||
.senda = _senda_orig,
|
||||
.sendnb = _sendnb_orig,
|
||||
.receive = _receive_orig,
|
||||
.do_kernel_call = _do_kernel_call_orig,
|
||||
.sendrec = _ipc_sendrec_intr,
|
||||
.send = _ipc_send_intr,
|
||||
.notify = _ipc_notify_intr,
|
||||
.senda = _ipc_senda_intr,
|
||||
.sendnb = _ipc_sendnb_intr,
|
||||
.receive = _ipc_receive_intr,
|
||||
.do_kernel_call = _do_kernel_call_intr,
|
||||
};
|
||||
|
||||
void __minix_init(void)
|
||||
{
|
||||
if((_minix_kernel_info_struct(&_minix_kerninfo)) != 0
|
||||
|| _minix_kerninfo->kerninfo_magic != KERNINFO_MAGIC) {
|
||||
if((get_minix_kerninfo(&_minix_kerninfo) != 0) ||
|
||||
(_minix_kerninfo->kerninfo_magic != KERNINFO_MAGIC))
|
||||
{
|
||||
_minix_kerninfo = NULL;
|
||||
} else if((_minix_kerninfo->ki_flags & MINIX_KIF_IPCVECS) &&
|
||||
_minix_kerninfo->minix_ipcvecs) {
|
||||
}
|
||||
else if((_minix_kerninfo->ki_flags & MINIX_KIF_IPCVECS) &&
|
||||
(_minix_kerninfo->minix_ipcvecs != NULL))
|
||||
{
|
||||
_minix_ipcvecs = *_minix_kerninfo->minix_ipcvecs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ register struct sigcontext *scp;
|
||||
sigset_t set;
|
||||
|
||||
/* The message can't be on the stack, because the stack will vanish out
|
||||
* from under us. The send part of sendrec will succeed, but when
|
||||
* from under us. The send part of ipc_sendrec will succeed, but when
|
||||
* a message is sent to restart the current process, who knows what will
|
||||
* be in the place formerly occupied by the message?
|
||||
*/
|
||||
|
||||
@@ -11,9 +11,9 @@ int _syscall(endpoint_t who, int syscallnr, message *msgptr)
|
||||
int status;
|
||||
|
||||
msgptr->m_type = syscallnr;
|
||||
status = sendrec(who, msgptr);
|
||||
status = ipc_sendrec(who, msgptr);
|
||||
if (status != 0) {
|
||||
/* 'sendrec' itself failed. */
|
||||
/* 'ipc_sendrec' itself failed. */
|
||||
/* XXX - strerror doesn't know all the codes */
|
||||
msgptr->m_type = status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user