Ejemplo n.º 1
0
void scanf(char* str, void* buf) {
    char temp_buf[100];
    
    __syscall1(11, (uint64_t)temp_buf);
   
    if(strcmp1(str, "%s") == 0)
    {
        buf = (char *)buf;
//        printf("----- %c", temp_buf[0]);
//        printf("in");
        //buf = temp_buf;
        int i = 0;
        while(temp_buf[i] != '\0')
            *(char *)buf++ = temp_buf[i++];
        *(char *)buf = '\0';
//        printf("%d", i);
    }
    else if(strcmp1(str, "%d") == 0)
    {
        *(int *)buf = stoi(temp_buf);
    }
    else if(strcmp1(str, "%x") == 0)
    {
        //buf = temp_buf;
    }

}
Ejemplo n.º 2
0
void child()
{
    char* argv[] = { "server", 0 };
    int pid = __syscall0(__NR_fork);
    if (pid == 0)
    {
	__syscall3(__NR_execve, (long) "./sslserver", (long) argv, (long) envp);
        myerror("exec");
        __syscall1(__NR_exit, 1);
    }
    else if (pid < 0)
    {
        errno = -pid;
        myerror("fork");
        __syscall1(__NR_exit, 1);
    }
}
Ejemplo n.º 3
0
Archivo: execve.c Proyecto: Fluray/OS-2
void execve(char *filename)
{

//	 __syscall3(SYSCALL_EXECVE,(uint64_t)filename, (uint64_t)argv, (uint64_t)envp);
  	 __syscall1(SYSCALL_EXECVE, (uint64_t) filename);


	
}
Ejemplo n.º 4
0
Archivo: server.c Proyecto: kmeaw/kusd
void STARTFUNC ()
{
  struct sysreq r;
  int fd;
  long n, s;
  uint64_t id[] = IDENT;

  __syscall1(__NR_close, 3);
acceptloop:
  fd = __syscall3(__NR_accept, 0, 0, 0);
  if (fd < 0)
  {
    myerror("accept");
    __syscall1(__NR_exit, 1);
  }
  if (fd != 3)
  {
    __syscall2(__NR_dup2, fd, 3);
    __syscall1(__NR_close, fd);
    fd = 3;
  }
  __syscall3 (__NR_write, fd, (long) id, sizeof(id));
  while (__syscall3(__NR_read, fd, (long) &r, sizeof(r)) > 0)
  {
//    fprintf (stderr, "(%x, %x, %x, %x, %x, %x, %x);\n", r.snr, r.sa, r.sb, r.sc, r.sd, r.se, r.sf);
    if (r.snr == 0 && r.sa == fd)
    {
      for (s = 0; r.sc && (n = __syscall3(__NR_read, fd, r.sb, r.sc)) > 0; s += n) { r.sb += n; r.sc -= n; }
      __syscall3(__NR_write, fd, (long) &s, sizeof(s));
    }
    else if (r.snr == 1 && r.sa == fd)
    {
      for (s = 0; r.sc && (n = __syscall3(__NR_write, fd, r.sb, r.sc)) > 0; s += n) { r.sb += n; r.sc -= n; }
      __syscall3(__NR_write, fd, (long) &s, sizeof(s));
    }
    else
    {
      r.sa = __syscall6(r.snr, r.sa, r.sb, r.sc, r.sd, r.se, r.sf);
      __syscall3(__NR_write, fd, (long) &r.sa, sizeof(r.sa));
    }
  }
  goto acceptloop;
}
/**
 * malloc does a system call to allocate memory on the user heap
 *
 * @param  size of the block of memory allocated
 * @param  uint32_t size > 0
 * @return returns a pointer to the allocated block of memory
 		   returns 0 if size is less than 1
 */ 
void* malloc(uint32_t size)
{
	if (size <= 0)
	{
		return 0;
	}
	//size will be passed into R0 for the syscall.
	long retval = __syscall1(SYSCALL_MALLOC,(long) size);

	//returns a pointer to begginning of allocated block(s)
	return (void*)retval;
}
/**
 * free does a system call to free an allocated block of memory on the heap
 *
 * @param  pointer to a block of memeory on the heap, does nothing if pointer is null
 * @param  void* ptr
 * @return nothing returned
 */
void free(void* ptr)
{
	//if null pointer, do nothing
	if (ptr == 0)
	{
		return 0;
	}

	//pointer of allocated block passed into R0
	long retval = __syscall1(SYSCALL_FREE,(long)ptr);

	//nothing returned
}
Ejemplo n.º 7
0
int close(int fd) {
	int * file_desc = (int *)0xfffffe0000000000;
	file_desc[0] = fd;
	__syscall1(7,(uint64_t)file_desc[0]);	
	return ((int)file_desc[0]);
}
Ejemplo n.º 8
0
void exit(int status) {
  __syscall1(EXIT, status);
}
Ejemplo n.º 9
0
/* allocate virtual memory */
void* sys_virtmem_alloc(ulong size)
{
    return (void*)__syscall1(SYSCALL_VIRTMEM_ALLOC, (ulong)size);
}
Ejemplo n.º 10
0
void hw_disable_irq (int irq) {
  long __res;
  __syscall1 (irq, hw_disable_irq_nr, __res);
}
Ejemplo n.º 11
0
void hw_restore_flags (int flags) {
  long __res;
  __syscall1 (flags, hw_restore_flags_nr, __res);
}
Ejemplo n.º 12
0
void do_exit(uint32_t status)
{
	__syscall1(SYS_EXIT, status);
}
Ejemplo n.º 13
0
#include <stdio.h>
#include <stdarg.h>
#include "../arch/arm/syscall_arch.h"

int printf(const char *restrict fmt, ...)
{
	//int ret;
	//va_list ap;
	//va_start(ap, fmt);
	//ret = vfprintf(stdout, fmt, ap);
	//va_end(ap);
    //return ret;
    long error = __syscall1(SYSCALL_PRINTF, (long)fmt);
	return error;
}
Ejemplo n.º 14
0
/* delete semaphore */
status_t sys_sem_delete(sem_id id)
{
    return __syscall1(SYSCALL_SEM_DELETE, (ulong)id);
}
Ejemplo n.º 15
0
/* terminate current thread */
void sys_thread_exit(int exitcode)
{
    __syscall1(SYSCALL_THREAD_EXIT, (ulong)exitcode);
}
Ejemplo n.º 16
0
/* put thread into temporary sleep */
void sys_thread_sleep(unsigned msec)
{
    __syscall1(SYSCALL_THREAD_SLEEP, (ulong)msec);
}
Ejemplo n.º 17
0
/* resume thread */
status_t sys_thread_resume(thread_id tid)
{
    return __syscall1(SYSCALL_THREAD_RESUME, (ulong)tid);
}
Ejemplo n.º 18
0
/* suspend thread */
status_t sys_thread_suspend(thread_id tid)
{
    return __syscall1(SYSCALL_THREAD_SUSPEND, (ulong)tid);
}
Ejemplo n.º 19
0
/* free virtual memory */
status_t sys_virtmem_free(void *ptr)
{
    return __syscall1(SYSCALL_VIRTMEM_FREE, (ulong)ptr);
}
Ejemplo n.º 20
0
int64_t wait(){
	/* Will wait for a child to wakeup itself */
	uint64_t pid = get_pid();
	return __syscall1(WAITPID, pid);
}
Ejemplo n.º 21
0
uint64_t closedir(char* name)
{
  return __syscall1(CLOSEDIR,(uint64_t)name);
}  
Ejemplo n.º 22
0
void xm_exit_domain (int status) {
    int res;
    __syscall1(status, exit_domain_nr, res);
}
Ejemplo n.º 23
0
int nanosleep(int sec)
{
    return __syscall1(SLEEP, sec);
}
Ejemplo n.º 24
0
int64_t wait_pid(uint64_t pid){
	return __syscall1(WAITPID, pid);
}
Ejemplo n.º 25
0
void hw_save_flags_and_cli (int *flags) {
  long __res;
  __syscall1 (flags, hw_save_flags_and_cli_nr, __res);
}
Ejemplo n.º 26
0
Archivo: brk.c Proyecto: Razbit/razos
void* sbrk(intptr_t incr)
{
	return (void*)__syscall1(SYS_SBRK, (uint32_t)incr);
}
Ejemplo n.º 27
0
void hw_end_irq (int irq) {
  long __res;
  __syscall1 (irq, hw_end_irq_nr, __res);
}
Ejemplo n.º 28
0
pid_t wait(int* status)
{
	return __syscall1(WAIT, (uint64_t)status);
}
Ejemplo n.º 29
0
void xm_pass_event (int event) {
    int res;
    __syscall1(event, pass_event_nr, res);
}
Ejemplo n.º 30
0
Archivo: brk.c Proyecto: Razbit/razos
int brk(void* addr)
{
	return (int)__syscall1(SYS_BRK, (uint32_t)addr);
}