Message type for SYS_SETALARM

Change-Id: I2c2ee24c19085cbd1e7ffba7b2db714b2561ff17
This commit is contained in:
Lionel Sambuc 2014-05-21 10:52:39 +02:00
parent 85e7cb92a9
commit 30eae10274
5 changed files with 30 additions and 27 deletions

View file

@ -300,11 +300,6 @@
#define DIO_PORT m2_l1 /* single port address */ #define DIO_PORT m2_l1 /* single port address */
#define DIO_VALUE m2_l2 /* single I/O value */ #define DIO_VALUE m2_l2 /* single I/O value */
/* Field names for SYS_SETALARM. */
#define ALRM_EXP_TIME m2_l1 /* expire time for the alarm call */
#define ALRM_ABS_TIME m2_i2 /* set to 1 to use absolute alarm time */
#define ALRM_TIME_LEFT m2_l1 /* how many ticks were remaining */
/* Field names for SYS_IRQCTL. */ /* Field names for SYS_IRQCTL. */
#define IRQ_REQUEST m5_s1 /* what to do? */ #define IRQ_REQUEST m5_s1 /* what to do? */
# define IRQ_SETPOLICY 1 /* manage a slot of the IRQ table */ # define IRQ_SETPOLICY 1 /* manage a slot of the IRQ table */

View file

@ -712,6 +712,15 @@ typedef struct {
} mess_lsys_krn_sys_sdevio; } mess_lsys_krn_sys_sdevio;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_sdevio); _ASSERT_MSG_SIZE(mess_lsys_krn_sys_sdevio);
typedef struct {
clock_t exp_time;
clock_t time_left;
int abs_time;
uint8_t padding[44];
} mess_lsys_krn_sys_setalarm;
_ASSERT_MSG_SIZE(mess_lsys_krn_sys_setalarm);
typedef struct { typedef struct {
int request; int request;
int vec_size; int vec_size;
@ -1456,6 +1465,7 @@ typedef struct {
mess_lsys_krn_schedule m_lsys_krn_schedule; mess_lsys_krn_schedule m_lsys_krn_schedule;
mess_lsys_krn_sys_memset m_lsys_krn_sys_memset; mess_lsys_krn_sys_memset m_lsys_krn_sys_memset;
mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio; mess_lsys_krn_sys_sdevio m_lsys_krn_sys_sdevio;
mess_lsys_krn_sys_setalarm m_lsys_krn_sys_setalarm;
mess_lsys_krn_sys_vdevio m_lsys_krn_sys_vdevio; mess_lsys_krn_sys_vdevio m_lsys_krn_sys_vdevio;
mess_lsys_pci_busc_get_bar m_lsys_pci_busc_get_bar; mess_lsys_pci_busc_get_bar m_lsys_pci_busc_get_bar;

View file

@ -2,9 +2,9 @@
* m_type: SYS_SETALARM * m_type: SYS_SETALARM
* *
* The parameters for this kernel call are: * The parameters for this kernel call are:
* m2_l1: ALRM_EXP_TIME (alarm's expiration time) * m_lsys_krn_sys_setalarm.exp_time (alarm's expiration time)
* m2_i2: ALRM_ABS_TIME (expiration time is absolute?) * m_lsys_krn_sys_setalarm.abs_time (expiration time is absolute?)
* m2_l1: ALRM_TIME_LEFT (return seconds left of previous) * m_lsys_krn_sys_setalarm.time_left (return seconds left of previous)
*/ */
#include "kernel/system.h" #include "kernel/system.h"
@ -24,12 +24,12 @@ int do_setalarm(struct proc * caller, message * m_ptr)
/* A process requests a synchronous alarm, or wants to cancel its alarm. */ /* A process requests a synchronous alarm, or wants to cancel its alarm. */
long exp_time; /* expiration time for this alarm */ long exp_time; /* expiration time for this alarm */
int use_abs_time; /* use absolute or relative time */ int use_abs_time; /* use absolute or relative time */
minix_timer_t *tp; /* the process' timer structure */ minix_timer_t *tp; /* the process' timer structure */
clock_t uptime; /* placeholder for current uptime */ clock_t uptime; /* placeholder for current uptime */
/* Extract shared parameters from the request message. */ /* Extract shared parameters from the request message. */
exp_time = m_ptr->ALRM_EXP_TIME; /* alarm's expiration time */ exp_time = m_ptr->m_lsys_krn_sys_setalarm.exp_time; /* alarm's expiration time */
use_abs_time = m_ptr->ALRM_ABS_TIME; /* flag for absolute time */ use_abs_time = m_ptr->m_lsys_krn_sys_setalarm.abs_time; /* flag for absolute time */
if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM); if (! (priv(caller)->s_flags & SYS_PROC)) return(EPERM);
/* Get the timer structure and set the parameters for this alarm. */ /* Get the timer structure and set the parameters for this alarm. */
@ -40,9 +40,9 @@ int do_setalarm(struct proc * caller, message * m_ptr)
/* Return the ticks left on the previous alarm. */ /* Return the ticks left on the previous alarm. */
uptime = get_monotonic(); uptime = get_monotonic();
if ((tp->tmr_exp_time != TMR_NEVER) && (uptime < tp->tmr_exp_time) ) { if ((tp->tmr_exp_time != TMR_NEVER) && (uptime < tp->tmr_exp_time) ) {
m_ptr->ALRM_TIME_LEFT = (tp->tmr_exp_time - uptime); m_ptr->m_lsys_krn_sys_setalarm.time_left = (tp->tmr_exp_time - uptime);
} else { } else {
m_ptr->ALRM_TIME_LEFT = 0; m_ptr->m_lsys_krn_sys_setalarm.time_left = 0;
} }
/* Finally, (re)set the timer depending on the expiration time. */ /* Finally, (re)set the timer depending on the expiration time. */

View file

@ -11,8 +11,7 @@ int abs_time; /* use absolute or relative expiration time */
* number can be SELF if the caller doesn't know its process number. * number can be SELF if the caller doesn't know its process number.
*/ */
message m; message m;
m.ALRM_EXP_TIME = exp_time; /* the expiration time */ m.m_lsys_krn_sys_setalarm.exp_time = exp_time; /* the expiration time */
m.ALRM_ABS_TIME = abs_time; /* time is absolute? */ m.m_lsys_krn_sys_setalarm.abs_time = abs_time; /* time is absolute? */
return _kernel_call(SYS_SETALARM, &m); return _kernel_call(SYS_SETALARM, &m);
} }

View file

@ -17,25 +17,24 @@ int tickdelay(clock_t ticks)
if (ticks <= 0) return OK; /* check for robustness */ if (ticks <= 0) return OK; /* check for robustness */
m.ALRM_EXP_TIME = ticks; /* request message after ticks */ m.m_lsys_krn_sys_setalarm.exp_time = ticks; /* request message after ticks */
m.ALRM_ABS_TIME = 0; /* ticks are relative to now */ m.m_lsys_krn_sys_setalarm.abs_time = 0; /* ticks are relative to now */
s = _kernel_call(SYS_SETALARM, &m); s = _kernel_call(SYS_SETALARM, &m);
if (s != OK) return(s); if (s != OK) return(s);
sef_receive(CLOCK,&m_alarm); /* await synchronous alarm */ sef_receive(CLOCK,&m_alarm); /* await synchronous alarm */
/* Check if we must reschedule the current alarm. */ /* Check if we must reschedule the current alarm. */
if (m.ALRM_TIME_LEFT > 0 && m.ALRM_TIME_LEFT != TMR_NEVER) { if (m.m_lsys_krn_sys_setalarm.time_left > 0 &&
m.ALRM_EXP_TIME = m.ALRM_TIME_LEFT - ticks; m.m_lsys_krn_sys_setalarm.time_left != TMR_NEVER) {
if (m.ALRM_EXP_TIME <= 0)
m.ALRM_EXP_TIME = 1; m.m_lsys_krn_sys_setalarm.exp_time =
m.m_lsys_krn_sys_setalarm.time_left - ticks;
if (m.m_lsys_krn_sys_setalarm.exp_time <= 0)
m.m_lsys_krn_sys_setalarm.exp_time = 1;
s = _kernel_call(SYS_SETALARM, &m); s = _kernel_call(SYS_SETALARM, &m);
} }
return(s); return(s);
} }