示例#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;
    }

}
示例#2
0
文件: manager.c 项目: yottatsa/kusd
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);
    }
}
示例#3
0
文件: execve.c 项目: 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);


	
}
示例#4
0
文件: server.c 项目: 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
}
示例#7
0
文件: close.c 项目: KVSamhitha/CLI-OS
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]);
}
示例#8
0
文件: exit.c 项目: gautamkmr/SBUnix
void exit(int status) {
  __syscall1(EXIT, status);
}
示例#9
0
文件: syscall.c 项目: skarpenko/phlox
/* allocate virtual memory */
void* sys_virtmem_alloc(ulong size)
{
    return (void*)__syscall1(SYSCALL_VIRTMEM_ALLOC, (ulong)size);
}
示例#10
0
文件: irqs.c 项目: anoane/partikle
void hw_disable_irq (int irq) {
  long __res;
  __syscall1 (irq, hw_disable_irq_nr, __res);
}
示例#11
0
文件: irqs.c 项目: anoane/partikle
void hw_restore_flags (int flags) {
  long __res;
  __syscall1 (flags, hw_restore_flags_nr, __res);
}
示例#12
0
文件: do_exit.c 项目: Razbit/razos
void do_exit(uint32_t status)
{
	__syscall1(SYS_EXIT, status);
}
示例#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;
}
示例#14
0
文件: syscall.c 项目: skarpenko/phlox
/* delete semaphore */
status_t sys_sem_delete(sem_id id)
{
    return __syscall1(SYSCALL_SEM_DELETE, (ulong)id);
}
示例#15
0
文件: syscall.c 项目: skarpenko/phlox
/* terminate current thread */
void sys_thread_exit(int exitcode)
{
    __syscall1(SYSCALL_THREAD_EXIT, (ulong)exitcode);
}
示例#16
0
文件: syscall.c 项目: skarpenko/phlox
/* put thread into temporary sleep */
void sys_thread_sleep(unsigned msec)
{
    __syscall1(SYSCALL_THREAD_SLEEP, (ulong)msec);
}
示例#17
0
文件: syscall.c 项目: skarpenko/phlox
/* resume thread */
status_t sys_thread_resume(thread_id tid)
{
    return __syscall1(SYSCALL_THREAD_RESUME, (ulong)tid);
}
示例#18
0
文件: syscall.c 项目: skarpenko/phlox
/* suspend thread */
status_t sys_thread_suspend(thread_id tid)
{
    return __syscall1(SYSCALL_THREAD_SUSPEND, (ulong)tid);
}
示例#19
0
文件: syscall.c 项目: skarpenko/phlox
/* free virtual memory */
status_t sys_virtmem_free(void *ptr)
{
    return __syscall1(SYSCALL_VIRTMEM_FREE, (ulong)ptr);
}
示例#20
0
int64_t wait(){
	/* Will wait for a child to wakeup itself */
	uint64_t pid = get_pid();
	return __syscall1(WAITPID, pid);
}
示例#21
0
uint64_t closedir(char* name)
{
  return __syscall1(CLOSEDIR,(uint64_t)name);
}  
示例#22
0
void xm_exit_domain (int status) {
    int res;
    __syscall1(status, exit_domain_nr, res);
}
示例#23
0
int nanosleep(int sec)
{
    return __syscall1(SLEEP, sec);
}
示例#24
0
int64_t wait_pid(uint64_t pid){
	return __syscall1(WAITPID, pid);
}
示例#25
0
文件: irqs.c 项目: anoane/partikle
void hw_save_flags_and_cli (int *flags) {
  long __res;
  __syscall1 (flags, hw_save_flags_and_cli_nr, __res);
}
示例#26
0
文件: brk.c 项目: Razbit/razos
void* sbrk(intptr_t incr)
{
	return (void*)__syscall1(SYS_SBRK, (uint32_t)incr);
}
示例#27
0
文件: irqs.c 项目: anoane/partikle
void hw_end_irq (int irq) {
  long __res;
  __syscall1 (irq, hw_end_irq_nr, __res);
}
示例#28
0
pid_t wait(int* status)
{
	return __syscall1(WAIT, (uint64_t)status);
}
示例#29
0
void xm_pass_event (int event) {
    int res;
    __syscall1(event, pass_event_nr, res);
}
示例#30
0
文件: brk.c 项目: Razbit/razos
int brk(void* addr)
{
	return (int)__syscall1(SYS_BRK, (uint32_t)addr);
}