Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

clib/RTOS.C

Go to the documentation of this file.
00001 /****************************************************************************
00002 *
00003 * (C) 2000 by BECK IPC GmbH
00004 *
00005 *  BECK IPC GmbH
00006 *  Garbenheimerstr. 38
00007 *  D-35578 Wetzlar
00008 *
00009 *  Phone : (49)-6441-905-240
00010 *  Fax   : (49)-6441-905-245
00011 *
00012 * ---------------------------------------------------------------------------
00013 * Module      : rtos.c
00014 *
00015 * Function    :   IPC@Chip SC12: RTOS api functions
00016 *                 (see html documentation of the RTOS API)
00017 *                 Use memory model large at your program, if you use this C file.
00018 *                 See html documentation of the RTOS API for details.
00019 *                 Use model Large at your application project, because not all pointer
00020 *                 parameters are declarded as far pointers
00021 * Author        : bartat
00022 * Date          : 19.01.00
00023 * ---------------------------------------------------------------------------
00024 
00025 $Header: RTOS.C, 12, 14.02.2002 10:47:27, Christoph Stoidner$
00026 
00027 $Log:
00028  12   IPC@CHIP  1.11        14.02.2002 10:47:27  Christoph Stoidner add Find
00029       Semaphore Function
00030  11   IPC@CHIP  1.10        16.01.2002 11:45:06  Christoph Stoidner add starteam
00031       directives
00032  10   IPC@CHIP  1.9         14.01.2002 13:18:37  Christoph Stoidner add new
00033       functions
00034  9    IPC@CHIP  1.8         02.07.2001 13:29:06  Markus Bartat   delete the send
00035       message/taskstart functions
00036  8    IPC@CHIP  1.7         19.06.2001 13:40:10  Markus Bartat   edit
00037  7    IPC@CHIP  1.6         19.06.2001 13:35:07  Markus Bartat   start: Added
00038       comments to the c functions
00039  6    IPC@CHIP  1.5         01.06.2001 12:20:26  Markus Bartat   added new
00040       functions
00041  5    IPC@CHIP  1.4         31.05.2001 16:18:25  Christoph Stoidner
00042  4    IPC@CHIP  1.3         31.05.2001 14:27:45  Christoph Stoidner
00043  3    IPC@CHIP  1.2         29.05.2001 16:11:08  Markus Bartat   modify comment
00044  2    IPC@CHIP  1.1         29.05.2001 16:03:57  Markus Bartat   added API call
00045       0x11 Create a task without starting it
00046  1    IPC@CHIP  1.0         14.02.2001 16:09:47  Christoph Stoidner
00047 $
00048 
00049 * History       :
00050 *
00051 *  Vx.yy                   Author  Changes
00052 *
00053 *             19.01.00       mb    Create
00054 *             22.07.00       mb    add timer procedure calls (see html documentation)
00055 *             20.08.00       mb    add task state API calls
00056 *             24.08.00       mb    add API calls suspend and resume tasks
00057 *             23.10.00       mb    add event group calls
00058 *             26.10.00       mb    add message exchange calls
00059 *             29.05.01       mb    add task create call without running the task
00060 *             01.06.01       mb    add get task state call without using taskmonitoring
00061 *****************************************************************************/
00062 #include <DOS.H>
00063 #include "clib/rtxapi.h"
00064 #include "clib/rtos.h"
00065 /*************************************************************************/
00066 /**********************************************************************************************/
00067 //Task control functions
00068 /***********************************************************************************************/
00069 //create/start a task
00070 /************************************************************************************************/
00071 int RTX_Create_Task(int far * taskID, TaskDefBlock  far * taskdefblock)
00072 {
00073   union  REGS  inregs;
00074   union  REGS  outregs;
00075   struct SREGS segregs;
00076 
00077 
00078   inregs.h.ah   = RTX_TASK_CREATE;
00079   inregs.x.bx   = FP_SEG(taskID);
00080   inregs.x.si   = FP_OFF(taskID);
00081   segregs.es    = FP_SEG(taskdefblock);
00082   inregs.x.di   = FP_OFF(taskdefblock);
00083   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00084 
00085   //return errorcode
00086   return outregs.x.ax;
00087 
00088 }
00089 
00090 int RTX_Create_Task_Without_Run(int far * taskID, TaskDefBlock  far * taskdefblock)
00091 {
00092   union  REGS  inregs;
00093   union  REGS  outregs;
00094   struct SREGS segregs;
00095 
00096 
00097   inregs.h.ah   = RTX_TASK_CREATE_WITHOUT_RUN;
00098   inregs.x.bx   = FP_SEG(taskID);
00099   inregs.x.si   = FP_OFF(taskID);
00100   segregs.es    = FP_SEG(taskdefblock);
00101   inregs.x.di   = FP_OFF(taskdefblock);
00102   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00103 
00104   //return errorcode
00105   return outregs.x.ax;
00106 
00107 }
00108 
00109 
00110 /*************************************************************************/
00111 //Delete a task
00112 /*************************************************************************/
00113 int RTX_Delete_Task(int taskID)
00114 {
00115   union  REGS  inregs;
00116   union  REGS  outregs;
00117 
00118   inregs.h.ah   = RTX_TASK_DELETE;
00119   inregs.x.bx   = taskID;
00120   int86(RTOSVECT,&inregs,&outregs);
00121   //return errorcode
00122   return outregs.x.ax;
00123 }
00124 
00125 
00126 /*************************************************************************/
00127 //Stop and kill a task
00128 /*************************************************************************/
00129 int RTX_Kill_Task(int taskID)
00130 {
00131   union  REGS  inregs;
00132   union  REGS  outregs;
00133 
00134   inregs.h.ah   = RTX_TASK_KILL;
00135   inregs.x.bx   = taskID;
00136   int86(RTOSVECT,&inregs,&outregs);
00137   //return errorcode
00138   return outregs.x.ax;
00139 }
00140 
00141 
00142 /*************************************************************************/
00143 //Go to sleep for a defined time
00144 /*************************************************************************/
00145 int RTX_Sleep_Time(unsigned int time_ms)
00146 {
00147   union  REGS  inregs;
00148   union  REGS  outregs;
00149 
00150   inregs.h.ah   = RTX_SLEEP_TIME;
00151   inregs.x.bx   = time_ms;
00152   int86(RTOSVECT,&inregs,&outregs);
00153   //return errorcode
00154   return outregs.x.ax;
00155 }
00156 
00157 
00158 /*************************************************************************/
00159 //Go to sleep, until  wakerequest
00160 /*************************************************************************/
00161 int RTX_Sleep_Request(void)
00162 {
00163   union  REGS  inregs;
00164   union  REGS  outregs;
00165 
00166   inregs.h.ah   = RTX_SLEEP_REQ;
00167   int86(RTOSVECT,&inregs,&outregs);
00168   //return errorcode
00169   return outregs.x.ax;
00170 }
00171 
00172 /*************************************************************************/
00173 //Wakeup a sleeping task
00174 /*************************************************************************/
00175 int RTX_Wakeup(int taskID)
00176 {
00177   union  REGS  inregs;
00178   union  REGS  outregs;
00179 
00180   inregs.h.ah   = RTX_WAKEUP_TASK;
00181   inregs.x.bx   = taskID;
00182   int86(RTOSVECT,&inregs,&outregs);
00183   //return errorcode
00184   return outregs.x.ax;
00185 }
00186 
00187 /*************************************************************************/
00188 //End execution of task by itself, this functions never returns
00189 /*************************************************************************/
00190 int RTX_End_Execution(void)
00191 {
00192   union  REGS  inregs;
00193   union  REGS  outregs;
00194 
00195   inregs.h.ah   = RTX_END_EXEC;
00196   int86(RTOSVECT,&inregs,&outregs);
00197   //return errorcode, avoid compiler warning
00198   return outregs.x.ax;
00199 }
00200 
00201 
00202 
00203 
00204 /*************************************************************************/
00205 //Change taskprio
00206 /*************************************************************************/
00207 int RTX_Change_TaskPrio(int taskID, int prio, int  far *error)
00208 {
00209   union  REGS  inregs;
00210   union  REGS  outregs;
00211 
00212   *error = 0;
00213   inregs.h.ah   = RTX_CHANGE_PRIO;
00214   inregs.x.bx   = taskID;
00215   inregs.x.cx   = prio;
00216   int86(RTOSVECT,&inregs,&outregs);
00217   //return errorcode
00218   if(outregs.x.dx!=0)
00219   {
00220    *error =outregs.x.ax;
00221    return outregs.x.dx;
00222   }
00223   return outregs.x.ax;
00224 }
00225 
00226 
00227 /*************************************************************************/
00228 //Get the ID of the current running task
00229 /*************************************************************************/
00230 int RTX_Get_TaskID(void)
00231 {
00232   union  REGS  inregs;
00233   union  REGS  outregs;
00234 
00235   inregs.h.ah   = RTX_GET_TASKID;
00236   int86(RTOSVECT,&inregs,&outregs);
00237   //return errorcode
00238   return outregs.x.ax;
00239 }
00240 
00241 
00242 
00243 /*************************************************************************/
00244 //access filesystem
00245 /*************************************************************************/
00246 int RTX_Access_Filesystem(void)
00247 {
00248   union  REGS  inregs;
00249   union  REGS  outregs;
00250   inregs.h.ah   = RTX_ACCESS_FILESYSTEM;
00251   int86(RTOSVECT,&inregs,&outregs);
00252 //  if((int)outregs.x.dx==-3)  //fileaccess ok, but reserving dta entry
00253                                //for findfirst/next failed
00254   return outregs.x.dx;
00255 }
00256 
00257 
00258 
00259 
00260 /*************************************************************************/
00261 //Get state of a task, using the taskmonitoring mode
00262 /*************************************************************************/
00263 int RTX_Get_Task_State(char * taskname, Task_StateData * taskdata, int * error)
00264 {
00265   union  REGS  inregs;
00266   union  REGS  outregs;
00267   struct SREGS segregs;
00268 
00269   *error=0;
00270 
00271   inregs.h.ah   = RTX_GET_TASK_STATE;
00272   segregs.es    = FP_SEG(taskname);
00273   inregs.x.di   = FP_OFF(taskname);
00274   segregs.ds    = FP_SEG(taskdata);
00275   inregs.x.si   = FP_OFF(taskdata);
00276 
00277   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00278   if(outregs.x.dx!=0)
00279   {
00280     *error=outregs.x.ax;
00281     return outregs.x.dx;
00282   }
00283   //return taskid
00284   return outregs.x.ax;
00285 }
00286 
00287 /*************************************************************************/
00288 //Get state of a task, without using taskmonitoring mode
00289 /*************************************************************************/
00290 int RTX_Get_Task_State_Ext(char * taskname, unsigned int * taskstate, int * error)
00291 {
00292   union  REGS  inregs;
00293   union  REGS  outregs;
00294   struct SREGS segregs;
00295 
00296   *error=0;
00297   *taskstate=0;
00298   inregs.h.ah   = RTX_GET_TASK_STATE_EXT;
00299   segregs.es    = FP_SEG(taskname);
00300   inregs.x.di   = FP_OFF(taskname);
00301   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00302   if(outregs.x.dx!=0)
00303   {
00304     *error=outregs.x.ax;
00305     return outregs.x.dx;
00306   }
00307   *taskstate=outregs.x.bx;
00308   //return taskid
00309   return outregs.x.ax;
00310 }
00311 
00312 
00313 /*************************************************************************/
00314 //Get task  list
00315 /*************************************************************************/
00316 int RTX_Get_Task_List(TaskList *tasklist, int length)
00317 {
00318    union  REGS  inregs;
00319    union  REGS  outregs;
00320    struct SREGS segregs;
00321 
00322    inregs.h.ah   = RTX_GET_TASK_LIST;
00323    segregs.es    = FP_SEG(tasklist);
00324    inregs.x.di   = FP_OFF(tasklist);
00325    inregs.x.cx   = length;
00326 
00327    int86x(RTOSVECT,&inregs,&outregs,&segregs);
00328    //return list length
00329    return outregs.x.bx;
00330 }
00331 
00332 /*************************************************************************/
00333 //Start taskmonitoring
00334 /*************************************************************************/
00335 void RTX_Start_Task_Monitor(void)
00336 {
00337   union  REGS  inregs;
00338   union  REGS  outregs;
00339 
00340   inregs.h.ah   = RTX_START_TASK_MONITOR;
00341   int86(RTOSVECT,&inregs,&outregs);
00342 }
00343 
00344 
00345 /*************************************************************************/
00346 //Start taskmonitoring
00347 /*************************************************************************/
00348 void RTX_Stop_Task_Monitor(void)
00349 {
00350   union  REGS  inregs;
00351   union  REGS  outregs;
00352 
00353   inregs.h.ah   = RTX_STOP_TASK_MONITOR;
00354   int86(RTOSVECT,&inregs,&outregs);
00355 }
00356 
00357 
00358 /*************************************************************************/
00359 //Suspend a  task
00360 /*************************************************************************/
00361 int RTX_Suspend_Task(int taskID)
00362 {
00363   union  REGS  inregs;
00364   union  REGS  outregs;
00365   inregs.h.ah   = RTX_SUSPEND_TASK;
00366   inregs.x.bx   = taskID;
00367   int86(RTOSVECT,&inregs,&outregs);
00368   //return errorcode
00369   return outregs.x.ax;
00370 }
00371 
00372 /*************************************************************************/
00373 //Resume a  task
00374 /*************************************************************************/
00375 int RTX_Resume_Task(int taskID)
00376 {
00377   union  REGS  inregs;
00378   union  REGS  outregs;
00379   inregs.h.ah   = RTX_RESUME_TASK;
00380   inregs.x.bx   = taskID;
00381   int86(RTOSVECT,&inregs,&outregs);
00382   //return errorcode
00383   return outregs.x.ax;
00384 }
00385 
00386 
00387 /*************************************************************************/
00388 //Restart a  task, killed with call 0x02
00389 /*************************************************************************/
00390 int RTX_Restart_Task(int taskID)
00391 {
00392   union  REGS  inregs;
00393   union  REGS  outregs;
00394   inregs.h.ah   = RTX_RESTART_TASK;
00395   inregs.x.bx   = taskID;
00396   int86(RTOSVECT,&inregs,&outregs);
00397   //return errorcode
00398   return outregs.x.ax;
00399 }
00400 
00401 
00402 
00403 
00404 /*************************************************************************/
00405 /*************************************************************************/
00406 //Semaphore functions
00407 /*************************************************************************/
00408 /*************************************************************************/
00409 
00410 /*************************************************************************/
00411 //Create a semaphore
00412 /*************************************************************************/
00413 int RTX_Create_Sem(int far * semID, char  far * name, int initvalue)
00414 {
00415   union  REGS  inregs;
00416   union  REGS  outregs;
00417   struct SREGS segregs;
00418 
00419 
00420   inregs.h.ah   = RTX_CREATE_SEM;
00421   inregs.x.bx   = FP_SEG(semID);
00422   inregs.x.si   = FP_OFF(semID);
00423 
00424   inregs.x.cx   = initvalue;
00425 
00426   segregs.es    = FP_SEG(name);
00427   inregs.x.di   = FP_OFF(name);
00428 
00429   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00430   //return errorcode
00431   return outregs.x.ax;
00432 }
00433 
00434 /*************************************************************************/
00435 //Delete a  semaphore
00436 /*************************************************************************/
00437 int RTX_Delete_Sem(int semID)
00438 {
00439   union  REGS  inregs;
00440   union  REGS  outregs;
00441 
00442   inregs.h.ah   = RTX_DELETE_SEM;
00443   inregs.x.bx   = semID;
00444   int86(RTOSVECT,&inregs,&outregs);
00445   //return errorcode
00446   return outregs.x.ax;
00447 }
00448 
00449 
00450 /*************************************************************************/
00451 //Free a  resource semaphore
00452 /*************************************************************************/
00453 int RTX_Free_Sem(int semID)
00454 {
00455   union  REGS  inregs;
00456   union  REGS  outregs;
00457 
00458   inregs.h.ah   = RTX_FREE_RES;
00459   inregs.x.bx   = semID;
00460   int86(RTOSVECT,&inregs,&outregs);
00461   //return errorcode
00462   return outregs.x.ax;
00463 }
00464 
00465 /*************************************************************************/
00466 //Get a  counting semaphore
00467 /*************************************************************************/
00468 int RTX_Get_Sem(int semID)
00469 {
00470   union  REGS  inregs;
00471   union  REGS  outregs;
00472 
00473   inregs.h.ah   = RTX_GET_SEM;
00474   inregs.x.bx   = semID;
00475   int86(RTOSVECT,&inregs,&outregs);
00476   //return errorcode
00477   return outregs.x.ax;
00478 }
00479 
00480 
00481 /*************************************************************************/
00482 //Release a  resoure semaphore
00483 /*************************************************************************/
00484 int RTX_Release_Sem(int semID)
00485 {
00486   union  REGS  inregs;
00487   union  REGS  outregs;
00488 
00489   inregs.h.ah   = RTX_RELEASE_SEM;
00490   inregs.x.bx   = semID;
00491   int86(RTOSVECT,&inregs,&outregs);
00492   //return errorcode
00493   return outregs.x.ax;
00494 }
00495 
00496 
00497 /*************************************************************************/
00498 //Reserve a  resoure semaphore (optional timeout)
00499 /*************************************************************************/
00500 int RTX_Reserve_Sem(int semID, long  far  * time_ms)
00501 {
00502   union  REGS  inregs;
00503   union  REGS  outregs;
00504   struct SREGS segregs;
00505   inregs.h.ah   = RTX_RESERVE_RES;
00506   inregs.x.bx   = semID;
00507   segregs.es    = FP_SEG(time_ms);
00508   inregs.x.di   = FP_OFF(time_ms);
00509 
00510   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00511   //return errorcode
00512   return outregs.x.ax;
00513 }
00514 
00515 /*************************************************************************/
00516 //Signal a  counting semaphore
00517 /*************************************************************************/
00518 int RTX_Signal_Sem(int semID)
00519 {
00520   union  REGS  inregs;
00521   union  REGS  outregs;
00522   inregs.h.ah   = RTX_SIGNAL_SEM;
00523   inregs.x.bx   = semID;
00524   int86(RTOSVECT,&inregs,&outregs);
00525   //return errorcode
00526   return outregs.x.ax;
00527 }
00528 
00529 
00530 
00531 
00532 /*************************************************************************/
00533 //Wait on a  counting semaphore (optional timeout)
00534 /*************************************************************************/
00535 int RTX_Wait_Sem(int semID, long  far  * time_ms)
00536 {
00537   union  REGS  inregs;
00538   union  REGS  outregs;
00539   struct SREGS segregs;
00540 
00541   inregs.h.ah   = RTX_WAIT_SEM;
00542   inregs.x.bx   = semID;
00543   segregs.es    = FP_SEG(time_ms);
00544   inregs.x.di   = FP_OFF(time_ms);
00545 
00546   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00547   //return errorcode
00548   return outregs.x.ax;
00549 }
00550 
00551 /*************************************************************************/
00552 //Find an semaphore, specified by 4 char name tag
00553 /*************************************************************************/
00554 int RTX_Find_Sem(int * ID, char * name)
00555 {
00556   union  REGS  inregs;
00557   union  REGS  outregs;
00558   struct SREGS segregs;
00559 
00560   *ID=0;
00561   inregs.h.ah   = RTX_FIND_SEM;
00562   segregs.es    = FP_SEG(name);
00563   inregs.x.di   = FP_OFF(name);
00564 
00565   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00566   if(outregs.x.dx==0)
00567   {
00568     *ID = outregs.x.ax;
00569     return 0;
00570   }
00571   return outregs.x.ax;
00572 }
00573 
00574 
00575 
00576 
00577 /*************************************************************************/
00578 /*************************************************************************/
00579 //Time/Date functions
00580 /*************************************************************************/
00581 /*************************************************************************/
00582 
00583 /*************************************************************************/
00584 //Get system time and date
00585 /*************************************************************************/
00586 int RTX_Get_TimeDate(TimeDate_Structure  far * td)
00587 {
00588   union  REGS  inregs;
00589   union  REGS  outregs;
00590 
00591   inregs.h.ah   = RTX_GET_TIMEDATE;
00592   inregs.x.bx   = FP_SEG(td);
00593   inregs.x.si   = FP_OFF(td);
00594   int86(RTOSVECT,&inregs,&outregs);
00595   //return errorcode
00596   return 0;
00597 }
00598 
00599 
00600 /*************************************************************************/
00601 //Set system time and date
00602 /*************************************************************************/
00603 int RTX_Set_TimeDate(TimeDate_Structure  far * td)
00604 {
00605   union  REGS  inregs;
00606   union  REGS  outregs;
00607 
00608   inregs.h.ah   = RTX_SET_TIMEDATE;
00609   inregs.x.bx   = FP_SEG(td);
00610   inregs.x.si   = FP_OFF(td);
00611   int86(RTOSVECT,&inregs,&outregs);
00612   //return errorcode
00613   return 0;
00614 }
00615 
00616 /*************************************************************************/
00617 //Get tick count of system clock
00618 /*************************************************************************/
00619 void RTX_Get_System_Ticks(unsigned long far * ticks)
00620 {
00621 
00622   union  REGS  inregs;
00623   union  REGS  outregs;
00624   inregs.h.ah   = RTX_GET_TICKS;
00625   inregs.x.bx   = FP_SEG(ticks);
00626   inregs.x.si   = FP_OFF(ticks);
00627   int86(RTOSVECT,&inregs,&outregs);
00628 }
00629 
00630 
00631 /*************************************************************************/
00632 //Install timer procedure
00633 /*************************************************************************/
00634 int RTX_Install_Timer(TimerProc_Structure far * TProcPtr)
00635 {
00636   union  REGS  inregs;
00637   union  REGS  outregs;
00638   struct SREGS segregs;
00639 
00640   inregs.h.ah   = RTX_INSTALL_TIMER;
00641   segregs.es    = FP_SEG(TProcPtr);
00642   inregs.x.di   = FP_OFF(TProcPtr);
00643 
00644   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00645   //return errorcode
00646   return outregs.x.ax;
00647 }
00648 
00649 /*************************************************************************/
00650 //Remove timer procedure
00651 /*************************************************************************/
00652 int RTX_Remove_Timer(unsigned int timerID)
00653 {
00654   union  REGS  inregs;
00655   union  REGS  outregs;
00656 
00657   inregs.h.ah   = RTX_REMOVE_TIMER;
00658   inregs.x.bx   = timerID;
00659   int86(RTOSVECT,&inregs,&outregs);
00660   //return errorcode
00661   return outregs.x.ax;
00662 }
00663 
00664 /*************************************************************************/
00665 //Start periodic execution of timer procedure
00666 /*************************************************************************/
00667 int RTX_Start_Timer(unsigned int timerID)
00668 {
00669   union  REGS  inregs;
00670   union  REGS  outregs;
00671 
00672   inregs.h.ah   = RTX_START_TIMER;
00673   inregs.x.bx   = timerID;
00674   int86(RTOSVECT,&inregs,&outregs);
00675   //return errorcode
00676   return outregs.x.ax;
00677 }
00678 
00679 /*************************************************************************/
00680 //Stop periodic execution of timer procedure
00681 /*************************************************************************/
00682 int RTX_Stop_Timer(unsigned int timerID)
00683 {
00684   union  REGS  inregs;
00685   union  REGS  outregs;
00686 
00687   inregs.h.ah   = RTX_STOP_TIMER;
00688   inregs.x.bx   = timerID;
00689   int86(RTOSVECT,&inregs,&outregs);
00690   //return errorcode
00691   return outregs.x.ax;
00692 }
00693 
00694 /*************************************************************************/
00695 //Create event group
00696 /*************************************************************************/
00697 int RTX_Create_EventGroup(unsigned int * ID, char * name, int init_value)
00698 {
00699   union  REGS  inregs;
00700   union  REGS  outregs;
00701   struct SREGS segregs;
00702 
00703   inregs.h.ah   = RTX_CREATE_EVENTGROUP;
00704 
00705   inregs.x.bx   = init_value;
00706   segregs.es    = FP_SEG(ID);
00707   inregs.x.di   = FP_OFF(ID);
00708   segregs.ds    = FP_SEG(name);
00709   inregs.x.si   = FP_OFF(name);
00710 
00711   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00712 
00713   return outregs.x.ax;
00714 }
00715 
00716 /*************************************************************************/
00717 //Delete an event group
00718 /*************************************************************************/
00719 int RTX_Delete_EventGroup(unsigned int ID)
00720 {
00721   union  REGS  inregs;
00722   union  REGS  outregs;
00723 
00724   inregs.h.ah   = RTX_DELETE_EVENTGROUP;
00725   inregs.x.bx   = ID;
00726   int86(RTOSVECT,&inregs,&outregs);
00727   //return errorcode
00728   return outregs.x.ax;
00729 }
00730 
00731 /*************************************************************************/
00732 //Signal events group
00733 /*************************************************************************/
00734 int RTX_Signal_Events(unsigned int ID, unsigned int event_mask, unsigned event_value)
00735 {
00736   union  REGS  inregs;
00737   union  REGS  outregs;
00738 
00739   inregs.h.ah   = RTX_SIGNAL_EVENTS;
00740   inregs.x.bx   = ID;
00741   inregs.x.cx   = event_mask;
00742   inregs.x.dx   = event_value;
00743   int86(RTOSVECT,&inregs,&outregs);
00744   //return errorcode
00745   return outregs.x.ax;
00746 }
00747 
00748 
00749 /*************************************************************************/
00750 //Wait for events
00751 /*************************************************************************/
00752 int RTX_Wait_For_Event(unsigned int ID, RTX_Wait_Event * event_ptr)
00753 {
00754   union  REGS  inregs;
00755   union  REGS  outregs;
00756   struct SREGS segregs;
00757 
00758   inregs.h.ah   = RTX_WAIT_EVENTS;
00759   inregs.x.bx   = ID;
00760   segregs.es    = FP_SEG(event_ptr);
00761   inregs.x.di   = FP_OFF(event_ptr);
00762   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00763   return outregs.x.ax;
00764 }
00765 
00766 
00767 /*************************************************************************/
00768 //Read current events on a group
00769 /*************************************************************************/
00770 int RTX_Get_EventGroup_State(unsigned int ID, unsigned int * Event)
00771 {
00772   union  REGS  inregs;
00773   union  REGS  outregs;
00774   struct SREGS segregs;
00775 
00776   inregs.h.ah   = RTX_GET_EVENTGROUP_STATE;
00777   inregs.x.bx   = ID;
00778   segregs.es    = FP_SEG(Event);
00779   inregs.x.di   = FP_OFF(Event);
00780   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00781   return outregs.x.ax;
00782 }
00783 
00784 /*************************************************************************/
00785 //Get the saved event flags/bits
00786 /*************************************************************************/
00787 int RTX_Get_Saved_Events(unsigned int * Event)
00788 {
00789   union  REGS  inregs;
00790   union  REGS  outregs;
00791 
00792   *Event=0;
00793   inregs.h.ah   = RTX_GET_EVENT_FLAGS;
00794   int86(RTOSVECT,&inregs,&outregs);
00795   if(outregs.x.dx==0)
00796   {
00797     *Event = outregs.x.ax;
00798     return 0;
00799   }
00800   return outregs.x.ax;
00801 }
00802 
00803 /*************************************************************************/
00804 //Find an event group, specified by 4 char name tag
00805 /*************************************************************************/
00806 int RTX_Find_EventGroup(unsigned int * ID, char * name)
00807 {
00808   union  REGS  inregs;
00809   union  REGS  outregs;
00810   struct SREGS segregs;
00811 
00812   *ID=0;
00813   inregs.h.ah   = RTX_FIND_EVENTGROUP;
00814   segregs.es    = FP_SEG(name);
00815   inregs.x.di   = FP_OFF(name);
00816 
00817   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00818   if(outregs.x.dx==0)
00819   {
00820     *ID = outregs.x.ax;
00821     return 0;
00822   }
00823   return outregs.x.ax;
00824 }
00825 
00826 
00827 /*************************************************************************/
00828 //Create message exchange
00829 /*************************************************************************/
00830 int RTX_Create_Msg(RTX_Msg * msg_ptr)
00831 {
00832   union  REGS  inregs;
00833   union  REGS  outregs;
00834   struct SREGS segregs;
00835   inregs.h.ah   = RTX_CREATE_MSG;
00836   segregs.es    = FP_SEG(msg_ptr);
00837   inregs.x.di   = FP_OFF(msg_ptr);
00838   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00839   return outregs.x.ax;
00840 }
00841 
00842 /*************************************************************************/
00843 //Delete a message exchange
00844 /*************************************************************************/
00845 int RTX_Delete_Msg(unsigned int ID)
00846 {
00847   union  REGS  inregs;
00848   union  REGS  outregs;
00849 
00850   inregs.h.ah   = RTX_DELETE_MSG;
00851   inregs.x.bx   = ID;
00852   int86(RTOSVECT,&inregs,&outregs);
00853   //return errorcode
00854   return outregs.x.ax;
00855 }
00856 
00857 
00858 
00859 /*************************************************************************/
00860 //Send a message to a message exchange
00861 /*************************************************************************/
00862 int RTX_Send_Msg(unsigned int ID, int prio, char * msg)
00863 {
00864   union  REGS  inregs;
00865   union  REGS  outregs;
00866   struct SREGS segregs;
00867   inregs.h.ah   = RTX_SEND_MSG;
00868   inregs.x.bx   = ID;
00869   inregs.x.cx   = prio;
00870   segregs.es    = FP_SEG(msg);
00871   inregs.x.di   = FP_OFF(msg);
00872   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00873   return outregs.x.ax;
00874 }
00875 
00876 
00877 
00878 
00879 /*************************************************************************/
00880 //Get a message from a message exchange, no wait
00881 /*************************************************************************/
00882 int RTX_Get_Msg(unsigned int ID, char * msg)
00883 {
00884   union  REGS  inregs;
00885   union  REGS  outregs;
00886   struct SREGS segregs;
00887   inregs.h.ah   = RTX_GET_MSG;
00888   inregs.x.bx   = ID;
00889   segregs.es    = FP_SEG(msg);
00890   inregs.x.di   = FP_OFF(msg);
00891   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00892   return outregs.x.ax;
00893 }
00894 
00895 
00896 
00897 /*************************************************************************/
00898 //Wait for a message, optional timeout
00899 /*************************************************************************/
00900 int RTX_Wait_For_Msg(RTX_Wait_Msg * msg_ptr)
00901 {
00902   union  REGS  inregs;
00903   union  REGS  outregs;
00904   struct SREGS segregs;
00905   inregs.h.ah   = RTX_WAIT_MSG;
00906   segregs.es    = FP_SEG(msg_ptr);
00907   inregs.x.di   = FP_OFF(msg_ptr);
00908   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00909   return outregs.x.ax;
00910 }
00911 
00912 
00913 /*************************************************************************/
00914 //Find an message exchange, specified by 4 char name tag
00915 /*************************************************************************/
00916 int RTX_Find_Msg(unsigned int * ID, char * name)
00917 {
00918   union  REGS  inregs;
00919   union  REGS  outregs;
00920   struct SREGS segregs;
00921 
00922   *ID=0;
00923   inregs.h.ah   = RTX_FIND_MSG;
00924   segregs.es    = FP_SEG(name);
00925   inregs.x.di   = FP_OFF(name);
00926 
00927   int86x(RTOSVECT,&inregs,&outregs,&segregs);
00928   if(outregs.x.dx==0)
00929   {
00930     *ID = outregs.x.ax;
00931     return 0;
00932   }
00933   return outregs.x.ax;
00934 }
00935 
00936 
00937 
00938 /*************************************************************************/
00939 //Disable Task Sheduling
00940 /*************************************************************************/
00941 void RTX_Disable_Task_Scheduling(void)
00942 {
00943   union  REGS  inregs;
00944   union  REGS  outregs;
00945 
00946   inregs.h.ah   = RTX_DISABLE_TASK_SCHEDULING;
00947   int86(RTOSVECT,&inregs,&outregs);
00948   return;
00949 }
00950 
00951 
00952 /*************************************************************************/
00953 //Enable Task Sheduling
00954 /*************************************************************************/
00955 void RTX_Enable_Task_Scheduling(void)
00956 {
00957   union  REGS  inregs;
00958   union  REGS  outregs;
00959 
00960   inregs.h.ah   = RTX_ENABLE_TASK_SCHEDULING;
00961   int86(RTOSVECT,&inregs,&outregs);
00962   return;
00963 }
00964 
00965 /*************************************************************************/
00966 //end rtos.c
00967 /*************************************************************************/

Generated on Sun Aug 4 21:47:27 2002 for k/os mp3v2 by doxygen1.2.16