Ignore:
Timestamp:
Aug 7, 2014, 4:57:07 PM (10 years ago)
Author:
alain
Message:

1) Introducing the new system call giet_get_xy() in stdio.h,

required for the free() funcyion in malloc.h

2) Fixing bugs in malloc.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_libs/stdio.c

    r382 r390  
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
    7 // The stdio.c and stdio.h files are part of the GIET_VM nano-kernel.
    8 // This library contains all user-level functions that contain a system call
    9 // to access protected or shared ressources.
    10 ///////////////////////////////////////////////////////////////////////////////////
    117
    128#include <stdarg.h>
    139#include <stdio.h>
    1410#include <giet_config.h>
     11
     12////////////////////////////////////////////////////////////////////////////////////
     13/////////////////////  MIPS32     related system calls /////////////////////////////
     14////////////////////////////////////////////////////////////////////////////////////
     15
     16/////////////////
     17int giet_procid()
     18{
     19    return sys_call( SYSCALL_PROCID,
     20                     0, 0, 0, 0 );
     21}
     22
     23////////////////////
     24int giet_proctime()
     25{
     26    return sys_call( SYSCALL_PROCTIME,
     27                     0, 0, 0, 0 );
     28}
     29
     30///////////////
     31int giet_rand()
     32{
     33    unsigned int x = sys_call(SYSCALL_PROCTIME,
     34                              0, 0, 0, 0);
     35    if ((x & 0xF) > 7)
     36    {
     37        return (x*x & 0xFFFF);
     38    }
     39    else
     40    {
     41        return (x*x*x & 0xFFFF);
     42    }
     43}
    1544
    1645////////////////////////////////////////////////////////////////////////////////////
     
    498527                   (unsigned int)buffer,
    499528                   count,
    500                    offset ) != count ) giet_exit("in giet_fat_read()");
     529                   offset ) != count ) giet_exit("ERROR in giet_fat_read()");
    501530}
    502531
     
    511540                   (unsigned int)buffer,
    512541                   count,
    513                    offset ) != count ) giet_exit("in giet_fat_write()");
     542                   offset ) != count ) giet_exit("ERROR in giet_fat_write()");
    514543}
    515544
     
    541570                   offset,
    542571                   whence,
    543                    0 ) ) giet_exit("in giet_fat_lseek()");
     572                   0 ) ) giet_exit("ERROR in giet_fat_lseek()");
    544573}
    545574
     
    549578    if ( sys_call( SYSCALL_FAT_FSTAT,
    550579                   fd,
    551                    0, 0, 0 ) )  giet_exit("in giet_fat_lseek()");
     580                   0, 0, 0 ) )  giet_exit("ERROR in giet_fat_lseek()");
    552581}
    553582
     
    557586    if ( sys_call( SYSCALL_FAT_CLOSE,
    558587                   fd,
    559                    0, 0, 0 ) )  giet_exit("in giet_fat_close()");
    560 }
    561 
    562 
    563 //////////////////////////////////////////////////////////////////////////////////
    564 ///////////////////// Miscellaneous system calls /////////////////////////////////
    565 //////////////////////////////////////////////////////////////////////////////////
    566 
    567 /////////////////
    568 int giet_procid()
    569 {
    570     return sys_call( SYSCALL_PROCID,
    571                      0, 0, 0, 0 );
    572 }
    573 
    574 ////////////////////
    575 int giet_proctime()
    576 {
    577     return sys_call( SYSCALL_PROCTIME,
    578                      0, 0, 0, 0 );
    579 }
     588                   0, 0, 0 ) )  giet_exit("ERROR in giet_fat_close()");
     589}
     590
     591
     592//////////////////////////////////////////////////////////////////////////////////
     593///////////////////// Task context  system calls /////////////////////////////////
     594//////////////////////////////////////////////////////////////////////////////////
    580595
    581596///////////////////////
     
    600615}
    601616
    602 ///////////////
    603 int giet_rand()
    604 {
    605     unsigned int x = sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0);
    606     if ((x & 0xF) > 7) {
    607         return (x*x & 0xFFFF);
    608     }
    609     else {
    610         return (x*x*x & 0xFFFF);
    611     }
    612 }
     617
     618//////////////////////////////////////////////////////////////////////////////////
     619///////////////////// Miscellaneous system calls /////////////////////////////////
     620//////////////////////////////////////////////////////////////////////////////////
    613621
    614622//////////////////////////////
     
    625633{
    626634    if ( condition == 0 ) giet_exit( string );
     635}
     636
     637//////////////////////////
     638void giet_context_switch()
     639{
     640    sys_call( SYSCALL_CTX_SWITCH,
     641              0, 0, 0, 0 );
    627642}
    628643
     
    636651                   (unsigned int) vobj_name,
    637652                   (unsigned int) vobj_vaddr,
    638                    0 ) )  giet_exit("in giet_vobj_get_vbase()");
     653                   0 ) )  giet_exit("ERROR in giet_vobj_get_vbase()");
    639654}
    640655
     
    646661                   cluster_id,
    647662                   (unsigned int) buffer,
    648                    0, 0) )  giet_exit("in giet_proc_number()");
    649 }
    650 
    651 //////////////////////////
    652 void giet_context_switch()
    653 {
    654     sys_call( SYSCALL_CTX_SWITCH,
    655               0, 0, 0, 0 );
     663                   0, 0) )  giet_exit("ERROR in giet_proc_number()");
    656664}
    657665
     
    666674                   (unsigned int)length,
    667675                   x,
    668                    y ) )  giet_exit("in giet_heap_info()");
     676                   y ) )  giet_exit("ERROR in giet_heap_info()");
     677}
     678
     679/////////////////////////////////////////
     680void giet_get_xy( void*         ptr,
     681                  unsigned int* px,
     682                  unsigned int* py )
     683{
     684    if ( sys_call( SYSCALL_GET_XY,
     685                   (unsigned int)ptr,
     686                   (unsigned int)px,
     687                   (unsigned int)py,
     688                   0 ) )  giet_exit("ERROR in giet_get_xy()");
    669689}
    670690
Note: See TracChangeset for help on using the changeset viewer.