Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /libc/include/syscall.h need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 
0019 
0020 struct sched_param
0021 {
0022   int sched_priority;
0023 
0024   /* Below are paramters used for window-constrained scheduling */
0025   int C;                        /* service quantum */
0026   int T;                        /* period */
0027   int m;                        /* mandatory instance count in a window */
0028   int k;                        /* window of requests  */
0029 };
0030 
0031 #define CLOBBERS1 "memory","cc","%ebx","%ecx","%edx","%esi","%edi"
0032 #define CLOBBERS2 "memory","cc","%ecx","%edx","%esi","%edi"
0033 #define CLOBBERS3 "memory","cc","%ebx","%edx","%esi","%edi"
0034 #define CLOBBERS4 "memory","cc","%ebx","%ecx","%esi","%edi"
0035 #define CLOBBERS5 "memory","cc","%edx","%esi","%edi"
0036 
0037 
0038 /* Syscall 0 used as a test syscall 
0039  *
0040  * Simply passes character arguments to the kernel for use in 
0041  * writing to video RAM
0042  */
0043 
0044 static inline void
0045 putchar (int c)
0046 {
0047 
0048   asm volatile ("int $0x30\n"::"a" (0L), "b" (c):CLOBBERS2);
0049 
0050 }
0051 
0052 static inline void
0053 usleep (unsigned usec)
0054 {
0055 
0056   asm volatile ("int $0x30\n"::"a" (1L), "b" (usec):CLOBBERS2);
0057 
0058 }
0059 
0060 static inline unsigned short
0061 fork (void)
0062 {
0063 
0064   unsigned int retval;
0065 
0066   asm volatile ("int $0x31\n":"=a" (retval)::CLOBBERS1);
0067 
0068   return (unsigned short) retval;
0069 }
0070 
0071 
0072 static inline void
0073 switch_to (unsigned pid)
0074 {
0075 
0076   asm volatile ("int $0x32\n"::"a" (pid):CLOBBERS1);
0077 
0078 }
0079 
0080 
0081 static inline void
0082 exec (char *file, char *argv[])
0083 {
0084 
0085   asm volatile ("int $0x33\n"::"a" (file), "b" (argv):CLOBBERS2);
0086 }
0087 
0088 
0089 static inline char
0090 getchar (void)
0091 {
0092 
0093   char c;
0094 
0095   asm volatile ("int $0x34\n":"=a" (c): "b" (0):CLOBBERS2);
0096 
0097   return c;
0098 }
0099 
0100 static inline unsigned int
0101 getcode (void)
0102 {
0103 
0104   unsigned int c;
0105 
0106   asm volatile ("int $0x34\n":"=a" (c): "b" (1):CLOBBERS2);
0107 
0108   return c;
0109 }
0110 
0111 static inline int
0112 open (const char *pathname, int flags)
0113 {
0114 
0115   int c;
0116 
0117   asm volatile ("int $0x35\n":"=a" (c):"a" (pathname), "b" (flags):CLOBBERS2);
0118 
0119   return c;
0120 }
0121 
0122 static inline int
0123 read (char *pathname, void *buf, int count)
0124 {
0125 
0126   int c;
0127 
0128   asm volatile ("int $0x36\n":"=a" (c):"a" (pathname), "b" (buf),
0129                 "c" (count):CLOBBERS5);
0130 
0131   return c;
0132 }
0133 
0134 
0135 static inline int
0136 uname (char *name)
0137 {
0138 
0139   int c;
0140 
0141   asm volatile ("int $0x37\n":"=a" (c):"a" (name):CLOBBERS1);
0142 
0143   return c;
0144 }
0145 
0146 
0147 static inline unsigned
0148 meminfo (void)
0149 {
0150 
0151   unsigned c;
0152 
0153   asm volatile ("int $0x38\n":"=a" (c):"a" (0L):CLOBBERS1);
0154 
0155   return c;
0156 }
0157 
0158 static inline unsigned
0159 shared_mem_alloc (void)
0160 {
0161   unsigned c;
0162 
0163   asm volatile ("int $0x38\n":"=a" (c):"a" (1L):CLOBBERS1);
0164 
0165   return c;
0166 }
0167 
0168 static inline void *
0169 shared_mem_attach (unsigned id)
0170 {
0171   unsigned c;
0172 
0173   asm volatile ("int $0x38\n":"=a" (c):"a" (2L), "d" (id):CLOBBERS4);
0174 
0175   return (void *) c;
0176 }
0177 
0178 static inline unsigned
0179 shared_mem_detach (void *addr)
0180 {
0181   unsigned c;
0182 
0183   asm volatile ("int $0x38\n":"=a" (c):"a" (3L), "d" ((unsigned) addr):CLOBBERS4);
0184 
0185   return c;
0186 }
0187 
0188 static inline unsigned
0189 shared_mem_free (unsigned id)
0190 {
0191   unsigned c;
0192 
0193   asm volatile ("int $0x38\n":"=a" (c):"a" (4L), "d" (id):CLOBBERS4);
0194 
0195   return c;
0196 }
0197 
0198 
0199 
0200 static inline unsigned
0201 time (void)
0202 {
0203 
0204   unsigned c;
0205 
0206   asm volatile ("int $0x39\n":"=a" (c):);
0207 
0208   return c;
0209 }
0210 
0211 
0212 static inline void _exit (int) __attribute__ ((noreturn));
0213 static inline void
0214 _exit (int status)
0215 {
0216 
0217   asm volatile ("int $0x3a\n"::"a" (status):CLOBBERS1);
0218 
0219   while (1);                    /* Shouldn't get here but stops gcc warning */
0220 }
0221 
0222 static inline int
0223 waitpid (int pid)
0224 {
0225 
0226   int ret;
0227 
0228   asm volatile ("int $0x3B\n":"=a" (ret):"a" (pid):CLOBBERS1);
0229 
0230   return ret;
0231 }
0232 
0233 
0234 static inline int
0235 sched_setparam (int pid, const struct sched_param *p)
0236 {
0237 
0238   int ret;
0239 
0240   asm volatile ("int $0x3C\n":"=a" (ret):"a" (pid), "b" (p):CLOBBERS2);
0241 
0242   return ret;
0243 }
0244 
0245 /* 
0246  * Local Variables:
0247  * indent-tabs-mode: nil
0248  * mode: C
0249  * c-file-style: "gnu"
0250  * c-basic-offset: 2
0251  * End: 
0252  */
0253 
0254 /* vi: set et sw=2 sts=2: */