From: Cristiano Giuffrida Date: Sat, 1 Mar 2014 23:40:33 +0000 (+0100) Subject: kernel: Extend the sys_statectl() interface. X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=refs%2Fchanges%2F76%2F3076%2F2;p=minix.git kernel: Extend the sys_statectl() interface. Change-Id: Ica37640f61513db9466dacf861a8148e3fb799d5 --- diff --git a/minix/include/minix/com.h b/minix/include/minix/com.h index fe8267513..2b2d33bf9 100644 --- a/minix/include/minix/com.h +++ b/minix/include/minix/com.h @@ -432,6 +432,7 @@ /* Subfunctions for SYS_STATECTL */ #define SYS_STATE_CLEAR_IPC_REFS 1 /* clear IPC references */ +#define SYS_STATE_SET_STATE_TABLE 2 /* set state map */ /* Subfunctions for SYS_SCHEDCTL */ # define SCHEDCTL_FLAG_KERNEL 1 /* mark kernel scheduler and remove diff --git a/minix/include/minix/ipc.h b/minix/include/minix/ipc.h index 6917bde51..0f056a61d 100644 --- a/minix/include/minix/ipc.h +++ b/minix/include/minix/ipc.h @@ -1177,8 +1177,10 @@ _ASSERT_MSG_SIZE(mess_lsys_krn_sys_sprof); typedef struct { int request; + void *address; + int length; - uint8_t padding[52]; + uint8_t padding[44]; } mess_lsys_krn_sys_statectl; _ASSERT_MSG_SIZE(mess_lsys_krn_sys_statectl); diff --git a/minix/include/minix/syslib.h b/minix/include/minix/syslib.h index c2ebcf2e4..3e4225833 100644 --- a/minix/include/minix/syslib.h +++ b/minix/include/minix/syslib.h @@ -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_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_privquery_mem(endpoint_t proc_ep, phys_bytes physstart, phys_bytes physlen); diff --git a/minix/kernel/priv.h b/minix/kernel/priv.h index 0bdd00949..d38101a6d 100644 --- a/minix/kernel/priv.h +++ b/minix/kernel/priv.h @@ -57,6 +57,8 @@ struct priv { int s_irq_tab[NR_IRQ]; vir_bytes s_grant_table; /* grant table address of process, 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. */ diff --git a/minix/kernel/system/do_privctl.c b/minix/kernel/system/do_privctl.c index 9909cc416..bcfd1d264 100644 --- a/minix/kernel/system/do_privctl.c +++ b/minix/kernel/system/do_privctl.c @@ -150,6 +150,8 @@ int do_privctl(struct proc * caller, message * m_ptr) priv(rp)->s_nr_irq= 0; priv(rp)->s_grant_table= 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. */ if (m_ptr->m_lsys_krn_sys_privctl.arg_ptr) diff --git a/minix/kernel/system/do_statectl.c b/minix/kernel/system/do_statectl.c index 4118216da..d9c9d5296 100644 --- a/minix/kernel/system/do_statectl.c +++ b/minix/kernel/system/do_statectl.c @@ -24,6 +24,11 @@ int do_statectl(struct proc * caller, message * m_ptr) */ clear_ipc_refs(caller, EDEADSRCDST); 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: printf("do_statectl: bad request %d\n", m_ptr->m_lsys_krn_sys_statectl.request); diff --git a/minix/lib/libblockdriver/driver.c b/minix/lib/libblockdriver/driver.c index 0c16b9aeb..1ccb090f2 100644 --- a/minix/lib/libblockdriver/driver.c +++ b/minix/lib/libblockdriver/driver.c @@ -106,7 +106,7 @@ void blockdriver_announce(int type) * will not restart statefully, and thus will skip this code. */ 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); } diff --git a/minix/lib/libchardriver/chardriver.c b/minix/lib/libchardriver/chardriver.c index 7a5a3603c..d3b443f2f 100644 --- a/minix/lib/libchardriver/chardriver.c +++ b/minix/lib/libchardriver/chardriver.c @@ -108,7 +108,7 @@ void chardriver_announce(void) * For this reason, there may blocked callers when a driver restarts. * 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); /* Publish a driver up event. */ diff --git a/minix/lib/libi2cdriver/i2cdriver.c b/minix/lib/libi2cdriver/i2cdriver.c index df631b225..0aca71db3 100644 --- a/minix/lib/libi2cdriver/i2cdriver.c +++ b/minix/lib/libi2cdriver/i2cdriver.c @@ -21,7 +21,7 @@ i2cdriver_announce(uint32_t bus) * For this reason, there may blocked callers when a driver restarts. * 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); } diff --git a/minix/lib/libsys/sys_statectl.c b/minix/lib/libsys/sys_statectl.c index 40c9a1e11..00279c6ad 100644 --- a/minix/lib/libsys/sys_statectl.c +++ b/minix/lib/libsys/sys_statectl.c @@ -1,10 +1,12 @@ #include "syslib.h" -int sys_statectl(int request) +int sys_statectl(int request, void* address, int length) { message m; 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); }