2011-12-11 03:45:04 +04:00
|
|
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
|
|
|
*/
|
2011-04-12 01:45:15 +04:00
|
|
|
#ifndef _SYSCALL_H
|
|
|
|
#define _SYSCALL_H
|
|
|
|
|
|
|
|
#define DECL_SYSCALL0(fn) int syscall_##fn()
|
|
|
|
#define DECL_SYSCALL1(fn,p1) int syscall_##fn(p1)
|
|
|
|
#define DECL_SYSCALL2(fn,p1,p2) int syscall_##fn(p1,p2)
|
|
|
|
#define DECL_SYSCALL3(fn,p1,p2,p3) int syscall_##fn(p1,p2,p3)
|
|
|
|
#define DECL_SYSCALL4(fn,p1,p2,p3,p4) int syscall_##fn(p1,p2,p3,p4)
|
|
|
|
#define DECL_SYSCALL5(fn,p1,p2,p3,p4,p5) int syscall_##fn(p1,p2,p3,p4,p5)
|
|
|
|
|
|
|
|
#define DEFN_SYSCALL0(fn, num) \
|
|
|
|
int syscall_##fn() { \
|
|
|
|
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num)); \
|
|
|
|
return a; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFN_SYSCALL1(fn, num, P1) \
|
|
|
|
int syscall_##fn(P1 p1) { \
|
|
|
|
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1)); \
|
|
|
|
return a; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFN_SYSCALL2(fn, num, P1, P2) \
|
|
|
|
int syscall_##fn(P1 p1, P2 p2) { \
|
|
|
|
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2)); \
|
|
|
|
return a; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFN_SYSCALL3(fn, num, P1, P2, P3) \
|
|
|
|
int syscall_##fn(P1 p1, P2 p2, P3 p3) { \
|
|
|
|
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2), "d" ((int)p3)); \
|
|
|
|
return a; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFN_SYSCALL4(fn, num, P1, P2, P3, P4) \
|
|
|
|
int syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4) { \
|
|
|
|
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2), "d" ((int)p3), "S" ((int)p4)); \
|
|
|
|
return a; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEFN_SYSCALL5(fn, num, P1, P2, P3, P4, P5) \
|
|
|
|
int syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { \
|
|
|
|
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2), "d" ((int)p3), "S" ((int)p4), "D" ((int)p5)); \
|
|
|
|
return a; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Core */
|
|
|
|
DECL_SYSCALL1(exit, int);
|
|
|
|
DECL_SYSCALL1(print, const char *);
|
|
|
|
|
|
|
|
/* Files */
|
|
|
|
DECL_SYSCALL1(close, int);
|
|
|
|
DECL_SYSCALL3(open, const char *, int, int);
|
|
|
|
DECL_SYSCALL3(read, int, char *, int);
|
|
|
|
DECL_SYSCALL3(write, int, char *, int);
|
|
|
|
DECL_SYSCALL2(fstat, int, void *);
|
|
|
|
DECL_SYSCALL1(isatty, int);
|
|
|
|
DECL_SYSCALL2(link, char *, char *);
|
|
|
|
DECL_SYSCALL1(unlink, char *);
|
|
|
|
DECL_SYSCALL3(lseek, int, int, int);
|
|
|
|
DECL_SYSCALL2(stat, const char *, void *);
|
|
|
|
|
|
|
|
/* Process Control */
|
|
|
|
DECL_SYSCALL0(getpid);
|
2011-04-17 22:26:31 +04:00
|
|
|
DECL_SYSCALL3(execve, char *, char **, char **);
|
2011-04-12 01:45:15 +04:00
|
|
|
DECL_SYSCALL0(fork);
|
|
|
|
DECL_SYSCALL2(kill, int, int);
|
2011-12-16 01:31:18 +04:00
|
|
|
DECL_SYSCALL1(wait, int);
|
2011-04-12 01:45:15 +04:00
|
|
|
|
|
|
|
/* Memory management */
|
|
|
|
DECL_SYSCALL1(sbrk, int);
|
|
|
|
|
2011-04-17 22:26:31 +04:00
|
|
|
DECL_SYSCALL2(gettimeofday, void *, void *);
|
2011-04-30 04:54:07 +04:00
|
|
|
DECL_SYSCALL0(getgraphicsaddress);
|
|
|
|
DECL_SYSCALL1(kbd_mode, int);
|
|
|
|
DECL_SYSCALL0(kbd_get);
|
|
|
|
DECL_SYSCALL3(lseek, int, int, int);
|
|
|
|
DECL_SYSCALL2(fstat, int, void *);
|
2011-04-30 06:41:29 +04:00
|
|
|
DECL_SYSCALL1(setgraphicsoffset, int);
|
2011-04-17 22:26:31 +04:00
|
|
|
|
2011-12-16 23:16:20 +04:00
|
|
|
DECL_SYSCALL0(getgraphicswidth);
|
|
|
|
DECL_SYSCALL0(getgraphicsheight);
|
VESA mode switching support.
BIOS execution is provided through the `v8086` module, which provides
software emulation of an 8086 processor. It is not currently working
with some BIOSes and may (read: probably will be) replaced with another
emulator (x86emu comes to mind) at some point in the near future. In the
meantime, the default video mode for QEMU works with this and it's
enough to get us on real VESA instead of fake VBE. The `bochs` module
will be renamed in a future commit. Userspace programs have been
adjusted to work at bitrates other than 32 *POORLY*. If you write pixels
left-to-right, they should work fine. They only work with 24-bpp
otherwise, and then you need to be careful of what pixels you are
writing when, or you will overwrite things in other pixels.
You may pass a commandline argument like the following to set display
modes:
vid=vesa,1024,768
Or for stranger modes under QEMU or Bochs, use the bochs VBE
initializer:
vid=bochs,1280,720
Note that the address of the linear framebuffer is still found via
hackish probing instead of PCI or trusting the VBE information, so if
you have things in the wrong memory ranges (0xE0000000+), be prepared to
have them get read.
Once again, this entire commit is a massive hack. I am happy that it
worked, and I will continue to make it less hacky, but in the meantime,
this is what we've got.
Happy holidays.
2011-12-25 10:40:40 +04:00
|
|
|
DECL_SYSCALL0(getgraphicsdepth);
|
2011-12-16 23:16:20 +04:00
|
|
|
|
2012-01-27 08:46:18 +04:00
|
|
|
DECL_SYSCALL0(getuid);
|
|
|
|
DECL_SYSCALL1(setuid, unsigned int);
|
|
|
|
|
2011-04-12 01:45:15 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
/*
|
|
|
|
* vim:tabstop=4
|
|
|
|
* vim:noexpandtab
|
|
|
|
* vim:shiftwidth=4
|
|
|
|
*/
|