home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / h / kernel < prev    next >
Encoding:
Text File  |  2006-09-17  |  5.6 KB  |  178 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/kernel.h,v $
  4.  * $Date: 2005/03/28 14:58:03 $
  5.  * $Revision: 1.10 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  * This file is intended to provide an interface between UnixLib and
  10.  * programs and/or libraries initially developed using Norcroft headers
  11.  * (in particular its kernel.h header).
  12.  * Any simularity between this and the Norcroft kernel.h file is probably
  13.  * due to having to use identical structs.
  14.  *
  15.  ***************************************************************************/
  16.  
  17. #ifndef __KERNEL_H
  18. #define __KERNEL_H
  19.  
  20. #ifndef __UNIXLIB_FEATURES_H
  21. #include <features.h>
  22. #endif
  23.  
  24. __BEGIN_DECLS
  25.  
  26. typedef struct
  27. {
  28.    int r[10];
  29. } _kernel_swi_regs;
  30.  
  31. typedef struct
  32. {
  33.    int load, exec;
  34.    int start, end;
  35. } _kernel_osfile_block;
  36.  
  37. typedef struct
  38. {
  39.    int errnum;
  40.    char errmess[252];
  41. } _kernel_oserror;
  42.  
  43. typedef struct stack_chunk
  44. {
  45.   unsigned long sc_mark;
  46.   struct stack_chunk *sc_next, *sc_prev;
  47.   unsigned long sc_size;
  48.   int (*sc_deallocate) (void);
  49. } _kernel_stack_chunk;
  50.  
  51. extern int _kernel_fpavailable (void) __THROW;
  52.  
  53. /* Passes argument string to SWI "OS_CLI". */
  54. extern int _kernel_oscli (const char *__s) __THROW __nonnull ((1));
  55.  
  56. #define _kernel_NONX 0x80000000
  57. /* Call the SWI specified by 'no'. 'in' points to a register block
  58.    for SWI entry. 'out' points to a register block for SWI exit.
  59.    The X bit is set by _kernel_swi unless bit 31 is set.  */
  60. extern _kernel_oserror *_kernel_swi (int __no,
  61.                      const _kernel_swi_regs *__in,
  62.                      _kernel_swi_regs *__out) __THROW;
  63.  
  64. /* Similar to _kernel_swi but the carry flag status is returned in
  65.    'carry'.  */
  66. extern _kernel_oserror *_kernel_swi_c (int __no,
  67.                        const _kernel_swi_regs *__in,
  68.                        _kernel_swi_regs *__out,
  69.                        int *__carry)
  70.      __THROW;
  71.  
  72. /* Return the last OS error since the last time _kernel_last_oserror
  73.    was called.  Return zero if no errors have occurred.  */
  74. extern _kernel_oserror *_kernel_last_oserror (void) __THROW __wur;
  75.  
  76. /* Perform an OS_Byte operation.
  77.    R1 is returned in the bottom byte, R2 in the second byte,
  78.    if carry set, then third byte = 1.  */
  79. extern int _kernel_osbyte (int __operation, int __x, int __y) __THROW;
  80.  
  81. /* Read a character from the OS input stream.  */
  82. extern int _kernel_osrdch (void) __THROW;
  83.  
  84. /* Write a character to the OS output streams.  The return value indicates
  85.    success or failure.  */
  86. extern int _kernel_oswrch (int __ch) __THROW;
  87.  
  88. /* Return the next byte from the file 'handle'. Return -1 on EOF.  */
  89. extern int _kernel_osbget (unsigned __handle) __THROW;
  90.  
  91. /* Write the byte 'ch' to the file 'handle'. Return success or failure.  */
  92. extern int _kernel_osbput (int __ch, unsigned __handle) __THROW;
  93.  
  94. /* Perform an OS_File operation. The _kernel_osfile_block provides
  95.    values for registers R2-R5.  */
  96. extern int _kernel_osfile (int __operation, const char *__name,
  97.                _kernel_osfile_block *__inout)
  98.      __THROW __nonnull ((2, 3));
  99.  
  100. typedef struct
  101. {
  102.   void * dataptr;
  103.   int nbytes, fileptr;
  104.   int buf_len;
  105.   char *wild_fld;
  106. } _kernel_osgbpb_block;
  107.  
  108. /* Read/write a number of bytes on file 'handle'. */
  109. extern int _kernel_osgbpb (int __operation, unsigned __handle,
  110.                _kernel_osgbpb_block *__inout)
  111.      __THROW __nonnull ((3));
  112.  
  113. /* Perform an OS_Word operation.  */
  114. extern int _kernel_osword (int __operation, int *__data)
  115.      __THROW __nonnull ((2));
  116.  
  117. /* Open or close a file. Open returns a file handle, close just
  118.    indicates success/failure.  */
  119. extern int _kernel_osfind (int __operation, char *__name)
  120.      __THROW __nonnull ((2));
  121.  
  122. /* Perform an OS_Args operation. Generally returns the value in R2,
  123.    unless op = 0.  */
  124. extern int _kernel_osargs (int __operation, unsigned __handle,
  125.                int __arg) __THROW;
  126.  
  127. /* Read the value of system variable 'name', placing the
  128.    result in 'buffer'.  */
  129. extern _kernel_oserror *
  130. _kernel_getenv (const char *__name, char *__buffer, unsigned __size)
  131.      __THROW __nonnull ((1, 2)) __wur;
  132.  
  133. /* Set the system variable 'name' with 'value'. If 'value == 0' then
  134.    'name' is deleted.  */
  135. extern _kernel_oserror *
  136. _kernel_setenv (const char *__name, const char *__value)
  137.      __THROW __nonnull ((1, 2)) __wur;
  138.  
  139. /* Unsigned divide and remainder function. Returns the remainder in R1. */
  140. extern unsigned int _kernel_udiv (unsigned int __divisor,
  141.                   unsigned int __dividend)
  142.      __THROW __attribute__ ((__const__)) __wur;
  143.  
  144. /* Unsigned remainder function.  */
  145. extern unsigned int _kernel_urem (unsigned int __divisor,
  146.                   unsigned int __dividend)
  147.      __THROW __attribute__ ((__const__)) __wur;
  148.  
  149. /* Unsigned divide and remainder function by 10.
  150.    Returns the remainder in R1. */
  151. extern unsigned int _kernel_udiv10 (unsigned int __dividend)
  152.      __THROW __attribute__ ((__const__)) __wur;
  153.  
  154. /* Signed divide and remainder function. Returns the remainder in R1. */
  155. extern int _kernel_sdiv (int __divisor, int __dividend)
  156.      __THROW __attribute__ ((__const__)) __wur;
  157.  
  158. /* Signed remainder function.  */
  159. extern int _kernel_srem (int __divisor, int __dividend)
  160.      __THROW __attribute__ ((__const__)) __wur;
  161.  
  162. /* Signed divide and remainder function by 10.
  163.    Returns the remainder in R1. */
  164. extern int _kernel_sdiv10 (int __dividend)
  165.      __THROW __attribute__ ((__const__)) __wur;
  166.  
  167. /* Return a pointer to the current stack chunk.  */
  168. extern _kernel_stack_chunk *_kernel_current_stack_chunk (void) __THROW;
  169.  
  170. /* Allocate and free blocks of memory for automatic storage, i.e.
  171.    associated with the current stack frame.  */
  172. extern void *__rt_allocauto (unsigned int __size);
  173. extern void __rt_freeauto (void *__autostorage);
  174.  
  175. __END_DECLS
  176.  
  177. #endif
  178.