machdep.h

Go to the documentation of this file.
00001 /*
00002 ** machdep.h for  in /root/work/lseos-0.2.5/libsys/machdep
00003 ** 
00004 ** Copyright (c)2004 Vianney Rancurel
00005 ** Login   <vianney@epita.fr>
00006 ** 
00007 ** Started on  Wed Apr 28 13:28:32 2004 Vianney Rancurel
00008  ** Last update Fri Feb 25 15:36:54 2005 Olivier Dembour
00009 */
00010 #ifndef __MACHDEP_MACHDEP_H__
00011 #define __MACHDEP_MACHDEP_H__   1
00012 
00013 #include <machdep/asm.h>
00014 #include <machdep/param.h>
00015 #include <machdep/stdarg.h>
00016 #include <machdep/segments.h>
00017 #include <machdep/cpufunc.h>
00018 #include <machdep/tss.h>
00019 #include <machdep/limits.h>
00020 #include <machdep/kinfo.h>
00021 #include <machdep/pte.h>
00022 #include <machdep/npx.h>
00023 #include <machdep/lock.h>
00024 #include <machdep/psl.h>
00025 #include <machdep/specialreg.h>
00026 #include <machdep/frame.h>
00027 #include <machdep/byte_swap.h>
00028 #include <machdep/ieeefp.h>
00029 #include <machdep/conio.h>
00030 #include <machdep/gates.h> 
00031 #include <machdep/gatesdef.h>
00032 #include <machdep/setjmp.h>
00033 
00034 #define ntohl(x)        ((in_addr_t)__byte_swap_long((in_addr_t)(x)))
00035 #define ntohs(x)        ((in_port_t)__byte_swap_word((in_port_t)(x)))
00036 #define htonl(x)        ((in_addr_t)__byte_swap_long((in_addr_t)(x)))
00037 #define htons(x)        ((in_port_t)__byte_swap_word((in_port_t)(x)))
00038 
00039 #define QUAD_HIGH(Quad) ((int32_t) (((quad_t)(Quad)) >> 32))
00040 #define QUAD_LOW(Quad)  ((int32_t) (((quad_t)(Quad)) & 0xffffffffLL))
00041 #define QUAD_MAKE(High, Low)    ((((quad_t)(High)) << 32)|\
00042                                 (((quad_t)(Low)) & 0xffffffffLL))
00043 
00044 /*
00045  * info located at end of user address space
00046  */
00047 typedef struct  s_pinfo
00048 {
00049   vaddr_t       wd;     
00050   vaddr_t       envp;
00051   u_int32_t     nfdescs;
00052   vaddr_t       fdescs;
00053   int32_t       fs_gate;
00054   u_int32_t     progopts;
00055 #define PROGOPT_EXECVE_BOOTFS           (1<<0u)
00056 #define PROGOPT_EXECVE_SHOW_ERRMSG      (1<<1u)
00057 #define PROGOPT_EMULATE_VFS             (1<<2u)
00058 #define PROGOPT_RT_MALLOC               (1<<3u)
00059 #define PROGOPT_SHARE_BINARIES          (1<<4u)
00060 #define PROGOPT_THREAD_WITH_IOMAP       (1<<5u)
00061   u_int32_t     execve_nbstkpgs;
00062 }               t_pinfo;
00063 #define PINFO_VADDR     (MAX_UADDR - sizeof (t_pinfo))
00064 
00065 typedef struct  s_fdesc
00066 {
00067   int           not_avail;      
00068   resid_t       resid;          
00069   u_int32_t     statusfl;       
00070   u_int32_t     fl;             
00071 }               t_fdesc;
00072 
00073 static __inline void
00074 nope(void)
00075 {
00076   /* nothing */
00077 }
00078 
00079 
00080 #define CORE_SYSCALL5(RetVal, Arg0, Arg1, Arg2, Arg3, Arg4, Arg5) \
00081 asm volatile ("int $0x81" \
00082         : "=a" (RetVal), "=c" (suberrno), "=b" (errno) \
00083         : "a" (Arg0), "b" ((long)(Arg1)), "c" ((long)(Arg2)), \
00084           "d" ((long)(Arg3)), "S" ((long)(Arg4)), "D" ((long)(Arg5)))
00085 
00086 /*
00087  * error codes manipulation routines
00088  */
00089 #define EC_DECL         int __errno_save, __suberrno_save
00090 #define EC_SAVE         __errno_save = errno;__suberrno_save = suberrno
00091 #define EC_RESTORE      errno = __errno_save;suberrno = __suberrno_save
00092 
00093 /*
00094  * trace macros
00095  */
00096 #define TRACE_IN(Str, Tcb) \
00097   if ((Tcb)->flags & TCBF_TRACED) \
00098     { \
00099       dprintf("%s: (%s) pid 0x%qx 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", \
00100              (Str), (Tcb)->name, (Tcb)->pid, \
00101              (Tcb)->tss.eax, (Tcb)->tss.ebx, (Tcb)->tss.ecx, \
00102              (Tcb)->tss.edx, (Tcb)->tss.esi, (Tcb)->tss.edi); \
00103     }
00104 #define TRACE_OUT(Str, Tcb) \
00105   if ((Tcb)->flags & TCBF_TRACED) \
00106     { \
00107       dprintf("%s: =0x%x 0x%x 0x%x\n", \
00108              (Str), \
00109              (Tcb)->tss.eax, (Tcb)->tss.ebx, (Tcb)->tss.ecx); \
00110     }
00111 
00112 typedef void (*t_nmi_fn)();
00113 
00114 /*
00115  * misc protos 
00116  */
00117 int     core_syscall(int arg1, int arg2, int arg3, int arg4,
00118                      int arg5, int arg6);
00119 int     gate_syscall(int gate, int arg1, int arg2, int arg3,
00120                      int arg4, int arg5, int arg6);
00121 
00122 int     rtr(void);
00123 int     ltr(int tr);
00124 
00125 void    *alloca(size_t size);
00126 
00127 extern void nmi_0();extern void nmi_1();extern void nmi_2();
00128 extern void nmi_3();extern void nmi_4();extern void nmi_5();
00129 extern void nmi_6();extern void nmi_7();extern void nmi_8();
00130 extern void nmi_9();extern void nmi_10();extern void nmi_10();
00131 extern void nmi_11();extern void nmi_12();extern void nmi_13();
00132 extern void nmi_14();extern void nmi_15();extern void nmi_16();
00133 extern void nmi_17();extern void nmi_18();extern void nmi_19();
00134 
00135 /*
00136  * globals
00137  */
00138 extern t_nmi_fn         nmi_fns[];
00139 extern int              nb_nmi_fns;
00140 
00141 extern int              fs_gate;
00142 
00143 extern int              nb_fdescs;
00144 extern t_fdesc          *fdescs;
00145 
00146 extern char             **environ;
00147 extern int              errno, suberrno;
00148 extern const char       *const sys_errlist[];
00149 extern const int        sys_nerr;
00150 
00151 extern u_int32_t        progopts;
00152 #define EMULATE_VFS()   (progopts & PROGOPT_EMULATE_VFS)
00153 #define RT_MALLOC()     (progopts & PROGOPT_RT_MALLOC)
00154 #define EXECVE_BOOTFS() (progopts & PROGOPT_EXECVE_BOOTFS)
00155 #define EXECVE_SHOW_ERRMSG() (progopts & PROGOPT_EXECVE_SHOW_ERRMSG)
00156 #define SHARE_BINARIES()        (progopts & PROGOPT_SHARE_BINARIES)
00157 
00158 extern u_int32_t        execve_nbstkpgs;        
00159 
00160 #endif

Generated on Wed May 24 23:04:17 2006 for LSE/OS by  doxygen 1.4.6