1*433d6423SLionel Sambuc /* This file contains some utility routines for SCHED. 2*433d6423SLionel Sambuc * 3*433d6423SLionel Sambuc * The entry points are: 4*433d6423SLionel Sambuc * no_sys: called for invalid system call numbers 5*433d6423SLionel Sambuc * sched_isokendpt: check the validity of an endpoint 6*433d6423SLionel Sambuc * sched_isemtyendpt check for validity and availability of endpoint slot 7*433d6423SLionel Sambuc * accept_message check whether message is allowed 8*433d6423SLionel Sambuc */ 9*433d6423SLionel Sambuc 10*433d6423SLionel Sambuc #include "sched.h" 11*433d6423SLionel Sambuc #include <machine/archtypes.h> 12*433d6423SLionel Sambuc #include <sys/resource.h> /* for PRIO_MAX & PRIO_MIN */ 13*433d6423SLionel Sambuc #include "schedproc.h" 14*433d6423SLionel Sambuc 15*433d6423SLionel Sambuc /*===========================================================================* 16*433d6423SLionel Sambuc * no_sys * 17*433d6423SLionel Sambuc *===========================================================================*/ no_sys(int who_e,int call_nr)18*433d6423SLionel Sambucint no_sys(int who_e, int call_nr) 19*433d6423SLionel Sambuc { 20*433d6423SLionel Sambuc /* A system call number not implemented by PM has been requested. */ 21*433d6423SLionel Sambuc printf("SCHED: in no_sys, call nr %d from %d\n", call_nr, who_e); 22*433d6423SLionel Sambuc return(ENOSYS); 23*433d6423SLionel Sambuc } 24*433d6423SLionel Sambuc 25*433d6423SLionel Sambuc 26*433d6423SLionel Sambuc /*===========================================================================* 27*433d6423SLionel Sambuc * sched_isokendpt * 28*433d6423SLionel Sambuc *===========================================================================*/ sched_isokendpt(int endpoint,int * proc)29*433d6423SLionel Sambucint sched_isokendpt(int endpoint, int *proc) 30*433d6423SLionel Sambuc { 31*433d6423SLionel Sambuc *proc = _ENDPOINT_P(endpoint); 32*433d6423SLionel Sambuc if (*proc < 0) 33*433d6423SLionel Sambuc return (EBADEPT); /* Don't schedule tasks */ 34*433d6423SLionel Sambuc if(*proc >= NR_PROCS) 35*433d6423SLionel Sambuc return (EINVAL); 36*433d6423SLionel Sambuc if(endpoint != schedproc[*proc].endpoint) 37*433d6423SLionel Sambuc return (EDEADEPT); 38*433d6423SLionel Sambuc if(!(schedproc[*proc].flags & IN_USE)) 39*433d6423SLionel Sambuc return (EDEADEPT); 40*433d6423SLionel Sambuc return (OK); 41*433d6423SLionel Sambuc } 42*433d6423SLionel Sambuc 43*433d6423SLionel Sambuc /*===========================================================================* 44*433d6423SLionel Sambuc * sched_isemtyendpt * 45*433d6423SLionel Sambuc *===========================================================================*/ sched_isemtyendpt(int endpoint,int * proc)46*433d6423SLionel Sambucint sched_isemtyendpt(int endpoint, int *proc) 47*433d6423SLionel Sambuc { 48*433d6423SLionel Sambuc *proc = _ENDPOINT_P(endpoint); 49*433d6423SLionel Sambuc if (*proc < 0) 50*433d6423SLionel Sambuc return (EBADEPT); /* Don't schedule tasks */ 51*433d6423SLionel Sambuc if(*proc >= NR_PROCS) 52*433d6423SLionel Sambuc return (EINVAL); 53*433d6423SLionel Sambuc if(schedproc[*proc].flags & IN_USE) 54*433d6423SLionel Sambuc return (EDEADEPT); 55*433d6423SLionel Sambuc return (OK); 56*433d6423SLionel Sambuc } 57*433d6423SLionel Sambuc 58*433d6423SLionel Sambuc /*===========================================================================* 59*433d6423SLionel Sambuc * accept_message * 60*433d6423SLionel Sambuc *===========================================================================*/ accept_message(message * m_ptr)61*433d6423SLionel Sambucint accept_message(message *m_ptr) 62*433d6423SLionel Sambuc { 63*433d6423SLionel Sambuc /* accept all messages from PM and RS */ 64*433d6423SLionel Sambuc switch (m_ptr->m_source) { 65*433d6423SLionel Sambuc 66*433d6423SLionel Sambuc case PM_PROC_NR: 67*433d6423SLionel Sambuc case RS_PROC_NR: 68*433d6423SLionel Sambuc return 1; 69*433d6423SLionel Sambuc 70*433d6423SLionel Sambuc } 71*433d6423SLionel Sambuc 72*433d6423SLionel Sambuc /* no other messages are allowable */ 73*433d6423SLionel Sambuc return 0; 74*433d6423SLionel Sambuc } 75