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