[158] | 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 */ |
---|
| 12 | unsigned int procid(); |
---|
| 13 | unsigned int proctime(); |
---|
| 14 | unsigned int procnumber(); |
---|
| 15 | |
---|
| 16 | /* TTY device related functions */ |
---|
| 17 | unsigned int tty_putc(char byte); |
---|
| 18 | unsigned int tty_puts(char *buf); |
---|
| 19 | unsigned int tty_putw(unsigned int val); |
---|
| 20 | unsigned int tty_getc(char *byte); |
---|
| 21 | unsigned int tty_getc_irq(char *byte); |
---|
| 22 | unsigned int tty_gets_irq(char *buf, unsigned int bufsize); |
---|
| 23 | unsigned int tty_getw_irq(unsigned int *val); |
---|
| 24 | unsigned int tty_printf(char *format,...); |
---|
| 25 | |
---|
| 26 | /* Timer device related functions */ |
---|
| 27 | unsigned int timer_set_mode(unsigned int mode); |
---|
| 28 | unsigned int timer_set_period(unsigned int period); |
---|
| 29 | unsigned int timer_reset_irq(); |
---|
| 30 | unsigned int timer_get_time(unsigned int *time); |
---|
| 31 | |
---|
| 32 | /* GCD coprocessor related functions */ |
---|
| 33 | unsigned int gcd_set_opa(unsigned int val); |
---|
| 34 | unsigned int gcd_set_opb(unsigned int val); |
---|
| 35 | unsigned int gcd_start(); |
---|
| 36 | unsigned int gcd_get_result(unsigned int *val); |
---|
| 37 | unsigned int gcd_get_status(unsigned int *val); |
---|
| 38 | |
---|
| 39 | /* Block device related functions */ |
---|
| 40 | unsigned int ioc_read(unsigned int lba, void *buffer, unsigned int count); |
---|
| 41 | unsigned int ioc_write(unsigned int lba, void *buffer, unsigned int count); |
---|
| 42 | unsigned int ioc_completed(); |
---|
| 43 | |
---|
| 44 | /* Frame buffer device related functions */ |
---|
| 45 | unsigned int fb_sync_read(unsigned int offset, void *buffer, unsigned int length); |
---|
| 46 | unsigned int fb_sync_write(unsigned int offset, void *buffer, unsigned int length); |
---|
| 47 | unsigned int fb_read(unsigned int offset, void *buffer, unsigned int length); |
---|
| 48 | unsigned int fb_write(unsigned int offset, void *buffer, unsigned int length); |
---|
| 49 | unsigned int fb_completed(); |
---|
| 50 | |
---|
| 51 | /* Software barrier related functions */ |
---|
| 52 | unsigned int barrier_init(unsigned int index, unsigned int count); |
---|
| 53 | unsigned int barrier_wait(unsigned int index); |
---|
| 54 | |
---|
| 55 | /* Misc */ |
---|
| 56 | void exit(); |
---|
| 57 | unsigned int rand(); |
---|
| 58 | unsigned int ctx_switch(); |
---|
| 59 | unsigned 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 | */ |
---|
| 70 | static 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 | |
---|