/**************************************************************************************
Copyright (c) 2002 The UbixOS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are prohibited.
$Id$
**************************************************************************************/
#include <ubixos/syscall.h>
#include <ubixos/syscalls.h>
#include <ubixos/schedule.h>
#include <ubixos/types.h>
#include <drivers/video.h>
asm(
".globl _sysCall \n"
"_sysCall: \n"
//" pusha \n" /* Save all registers */
//" pushw %ds \n" /* Set up the data segment */
//" pushw %es \n"
//" pushw %ss \n" /* Note that ss is always valid */
//" pushw %ss \n"
//" popw %ds \n"
//" popw %es \n"
" cmpl totalCalls,%eax \n"
" jae invalidCall \n"
" call *systemCalls(,%eax,4) \n"
//" popw %es \n"
//" popw %ds \n" /* Restore registers */
//" popa \n"
" iret \n" /* Exit interrupt */
);
void invalidCall() {
kprintf("Invalid System Call!!\n");
//_current->status = AVAILABLE;
//schedule();
}
void sysFwrite() {
char *ptr;
char data[1024];
int i=0;
int size;
int fd;
asm (
""
: "=b" (ptr),"=c" (size),"=d" (fd)
);
if (fd == 0) {
for (i=0;i<size;i++) {
data[i] = ptr[i];
}
kprintf("%s",data);
}
else {
kprintf("Id: [%i],Size: [%i]\n",fd,size);
}
}
void sysGetpid() {
int *pid;
asm (
"movl %%ebx,%0\n"
: "=g" (pid)
);
kprintf("First: [%i]\n",pid);
pid = _current->id;
kprintf("Real: [%i]\n",pid);
}