source: soft/giet_vm/libs/stdio.h @ 158

Last change on this file since 158 was 158, checked in by alain, 12 years ago

Introducing the giet_vm and some example applications

File size: 3.0 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : stdio.h         
3// Date     : 01/04/2010
4// Author   : alain greiner & Joel Porquet
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7
8#ifndef _STDIO_H
9#define _STDIO_H
10
11/* MIPS32 related functions */
12unsigned int procid();
13unsigned int proctime();
14unsigned int procnumber();
15
16/* TTY device related functions */
17unsigned int tty_putc(char byte);
18unsigned int tty_puts(char *buf);
19unsigned int tty_putw(unsigned int val);
20unsigned int tty_getc(char *byte);
21unsigned int tty_getc_irq(char *byte);
22unsigned int tty_gets_irq(char *buf, unsigned int bufsize);
23unsigned int tty_getw_irq(unsigned int *val);
24unsigned int tty_printf(char *format,...);
25
26/* Timer device related functions */
27unsigned int timer_set_mode(unsigned int mode);
28unsigned int timer_set_period(unsigned int period);
29unsigned int timer_reset_irq();
30unsigned int timer_get_time(unsigned int *time);
31
32/* GCD coprocessor related functions */
33unsigned int gcd_set_opa(unsigned int val);
34unsigned int gcd_set_opb(unsigned int val);
35unsigned int gcd_start();
36unsigned int gcd_get_result(unsigned int *val);
37unsigned int gcd_get_status(unsigned int *val);
38
39/* Block device related functions */
40unsigned int ioc_read(unsigned int lba, void *buffer, unsigned int count);
41unsigned int ioc_write(unsigned int lba, void *buffer, unsigned int count);
42unsigned int ioc_completed();
43
44/* Frame buffer device related functions */
45unsigned int fb_sync_read(unsigned int offset, void *buffer, unsigned int length);
46unsigned int fb_sync_write(unsigned int offset, void *buffer, unsigned int length);
47unsigned int fb_read(unsigned int offset, void *buffer, unsigned int length);
48unsigned int fb_write(unsigned int offset, void *buffer, unsigned int length);
49unsigned int fb_completed();
50
51/* Software barrier related functions */
52unsigned int barrier_init(unsigned int index, unsigned int count);
53unsigned int barrier_wait(unsigned int index);
54
55/* Misc */
56void exit();
57unsigned int rand();
58unsigned int ctx_switch();
59unsigned int mwmr_base(char* vspace_name, char* mwmr_name, void* buffer);
60
61/*
62 * memcpy function
63 *
64 * This function is likely not to be called directly but GCC can automatically
65 * issue call to it during compilation so we must provide it. 'static inline'
66 * so the function's code is directly included when used.
67 *
68 * Code taken from MutekH.
69 */
70static inline void *memcpy(void *_dst, const void *_src, unsigned int size)
71{
72    unsigned int *dst = _dst;
73    const unsigned int *src = _src;
74
75    /* if source and destination buffer are word-aligned,
76     * then copy word-by-word */
77    if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))
78        while (size > 3) {
79            *dst++ = *src++;
80            size -= 4;
81        }
82
83    unsigned char *cdst = (unsigned char*)dst;
84    unsigned char *csrc = (unsigned char*)src;
85
86    /* byte-by-byte copy */
87    while (size--) {
88        *cdst++ = *csrc++;
89    }
90    return _dst;
91}
92
93#endif
94
Note: See TracBrowser for help on using the repository browser.