kernel: Extend the sys_statectl() interface.

Change-Id: Ica37640f61513db9466dacf861a8148e3fb799d5
This commit is contained in:
Cristiano Giuffrida 2014-03-02 00:40:33 +01:00 committed by David van Moolenbroek
parent 606626c691
commit 41022be182
10 changed files with 20 additions and 6 deletions

View file

@ -432,6 +432,7 @@
/* Subfunctions for SYS_STATECTL */ /* Subfunctions for SYS_STATECTL */
#define SYS_STATE_CLEAR_IPC_REFS 1 /* clear IPC references */ #define SYS_STATE_CLEAR_IPC_REFS 1 /* clear IPC references */
#define SYS_STATE_SET_STATE_TABLE 2 /* set state map */
/* Subfunctions for SYS_SCHEDCTL */ /* Subfunctions for SYS_SCHEDCTL */
# define SCHEDCTL_FLAG_KERNEL 1 /* mark kernel scheduler and remove # define SCHEDCTL_FLAG_KERNEL 1 /* mark kernel scheduler and remove

View file

@ -1177,8 +1177,10 @@ _ASSERT_MSG_SIZE(mess_lsys_krn_sys_sprof);
typedef struct { typedef struct {
int request; int request;
void *address;
int length;
uint8_t padding[52]; uint8_t padding[44];
} mess_lsys_krn_sys_statectl; } mess_lsys_krn_sys_statectl;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_statectl); _ASSERT_MSG_SIZE(mess_lsys_krn_sys_statectl);

View file

@ -49,7 +49,7 @@ int sys_schedctl(unsigned flags, endpoint_t proc_ep, int priority, int
int sys_runctl(endpoint_t proc_ep, int action, int flags); int sys_runctl(endpoint_t proc_ep, int action, int flags);
int sys_update(endpoint_t src_ep, endpoint_t dst_ep); int sys_update(endpoint_t src_ep, endpoint_t dst_ep);
int sys_statectl(int request); int sys_statectl(int request, void* address, int length);
int sys_privctl(endpoint_t proc_ep, int req, void *p); int sys_privctl(endpoint_t proc_ep, int req, void *p);
int sys_privquery_mem(endpoint_t proc_ep, phys_bytes physstart, int sys_privquery_mem(endpoint_t proc_ep, phys_bytes physstart,
phys_bytes physlen); phys_bytes physlen);

View file

@ -57,6 +57,8 @@ struct priv {
int s_irq_tab[NR_IRQ]; int s_irq_tab[NR_IRQ];
vir_bytes s_grant_table; /* grant table address of process, or 0 */ vir_bytes s_grant_table; /* grant table address of process, or 0 */
int s_grant_entries; /* no. of entries, or 0 */ int s_grant_entries; /* no. of entries, or 0 */
vir_bytes s_state_table; /* state table address of process, or 0 */
int s_state_entries; /* no. of entries, or 0 */
}; };
/* Guard word for task stacks. */ /* Guard word for task stacks. */

View file

@ -150,6 +150,8 @@ int do_privctl(struct proc * caller, message * m_ptr)
priv(rp)->s_nr_irq= 0; priv(rp)->s_nr_irq= 0;
priv(rp)->s_grant_table= 0; priv(rp)->s_grant_table= 0;
priv(rp)->s_grant_entries= 0; priv(rp)->s_grant_entries= 0;
priv(rp)->s_state_table= 0;
priv(rp)->s_state_entries= 0;
/* Override defaults if the caller has supplied a privilege structure. */ /* Override defaults if the caller has supplied a privilege structure. */
if (m_ptr->m_lsys_krn_sys_privctl.arg_ptr) if (m_ptr->m_lsys_krn_sys_privctl.arg_ptr)

View file

@ -24,6 +24,11 @@ int do_statectl(struct proc * caller, message * m_ptr)
*/ */
clear_ipc_refs(caller, EDEADSRCDST); clear_ipc_refs(caller, EDEADSRCDST);
return(OK); return(OK);
case SYS_STATE_SET_STATE_TABLE:
/* Set state table for the caller. */
priv(caller)->s_state_table = (vir_bytes) m_ptr->m_lsys_krn_sys_statectl.address;
priv(caller)->s_state_entries = m_ptr->m_lsys_krn_sys_statectl.length;
return(OK);
default: default:
printf("do_statectl: bad request %d\n", printf("do_statectl: bad request %d\n",
m_ptr->m_lsys_krn_sys_statectl.request); m_ptr->m_lsys_krn_sys_statectl.request);

View file

@ -106,7 +106,7 @@ void blockdriver_announce(int type)
* will not restart statefully, and thus will skip this code. * will not restart statefully, and thus will skip this code.
*/ */
if (type == SEF_INIT_RESTART) { if (type == SEF_INIT_RESTART) {
if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK) if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS, 0, 0)) != OK)
panic("blockdriver_init: sys_statectl failed: %d", r); panic("blockdriver_init: sys_statectl failed: %d", r);
} }

View file

@ -108,7 +108,7 @@ void chardriver_announce(void)
* For this reason, there may blocked callers when a driver restarts. * For this reason, there may blocked callers when a driver restarts.
* Ask the kernel to unblock them (if any). * Ask the kernel to unblock them (if any).
*/ */
if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK) if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS, 0, 0)) != OK)
panic("chardriver_announce: sys_statectl failed: %d", r); panic("chardriver_announce: sys_statectl failed: %d", r);
/* Publish a driver up event. */ /* Publish a driver up event. */

View file

@ -21,7 +21,7 @@ i2cdriver_announce(uint32_t bus)
* For this reason, there may blocked callers when a driver restarts. * For this reason, there may blocked callers when a driver restarts.
* Ask the kernel to unblock them (if any). * Ask the kernel to unblock them (if any).
*/ */
if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS)) != OK) { if ((r = sys_statectl(SYS_STATE_CLEAR_IPC_REFS, 0, 0)) != OK) {
panic("chardriver_init: sys_statectl failed: %d", r); panic("chardriver_init: sys_statectl failed: %d", r);
} }

View file

@ -1,10 +1,12 @@
#include "syslib.h" #include "syslib.h"
int sys_statectl(int request) int sys_statectl(int request, void* address, int length)
{ {
message m; message m;
m.m_lsys_krn_sys_statectl.request = request; m.m_lsys_krn_sys_statectl.request = request;
m.m_lsys_krn_sys_statectl.address = address;
m.m_lsys_krn_sys_statectl.length = length;
return _kernel_call(SYS_STATECTL, &m); return _kernel_call(SYS_STATECTL, &m);
} }