Imported Upstream version 2.9.0
[debian/cc1111] / device / include / pic16 / stdio.h
1 /*-------------------------------------------------------------------------
2   stdio.h - ANSI functions forward declarations
3
4    Ported to PIC16 port by Vangelis Rokas, 2004 (vrokas@otenet.gr)
5
6              Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1998)
7
8    This program is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published by the
10    Free Software Foundation; either version 2, or (at your option) any
11    later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22    In other words, you are welcome to use, share and improve this program.
23    You are forbidden to forbid anyone else to use, share and improve
24    what you give them.   Help stamp out software-hoarding!
25
26    As a special exception, if you link this library with other files,
27    some of which are compiled with SDCC, to produce an executable,
28    this library does not by itself cause the resulting executable
29    to be covered by the GNU General Public License.
30    This exception does not however invalidate any other reasons why
31    the executable file might be covered by the GNU General Public License.
32 -------------------------------------------------------------------------*/
33
34 #ifndef __STDIO_H
35 #define __STDIO_H 1
36
37 /* link the C library */
38 #pragma library c
39
40 #include <stdarg.h>
41
42 #include <sdcc-lib.h>
43
44 #ifndef NULL
45   #define NULL (void *)0
46 #endif
47
48 #ifndef _SIZE_T_DEFINED
49 #define _SIZE_T_DEFINED
50   typedef unsigned int size_t;
51 #endif
52
53 /* stream descriptor definition */
54 typedef char *FILE;
55
56 /* USART and MSSP module stream descriptors */
57
58 /* since FILE is declared as a generic pointer,
59  * the upper byte is used to dereference the pointer
60  * information. For the stream descriptors we
61  * use the 5th bit and the lower nubble bits.
62  * Descriptors are denoted by an 1 in bit 5,
63  * further dereference is made for:
64  * <stream>     <3:0> bits
65  *     USART     0 (0x0)
66  *     MSSP      1 (0x1)
67  *     USER     15 (0xf)
68  *
69  * There is a special value for GPSIM specific (see below)
70  * which is:
71  *     GPSIM    14 (0xe)
72  *
73  *
74  * if further stream descriptors need to be added then more
75  * bits of the upper byte can be used
76  */
77
78 #define USART_DEREF     0x0
79 #define MSSP_DEREF      0x1
80 #define USER_DEREF      0xf
81
82 #define STREAM_USART    ((FILE *)(0x00200000UL))
83 #define STREAM_MSSP     ((FILE *)(0x00210000UL))
84 #define STREAM_USER     ((FILE *)(0x002f0000UL))
85
86 /* this is a custom dereference which points to a custom
87  * port of GPSIM simulator. This port redirects characters
88  * to /tmp/gpsim.debug.1 file (used for debugging purposes)
89  * NOTICE: This feature is not part of the official gpsim
90  * distribution. Contact vrokas AT users.sourceforge.net
91  * for more info */
92 #define GPSIM_DEREF     0xe
93 #define STREAM_GPSIM    ((FILE *)(0x002e0000UL))
94
95 extern FILE *stdin;
96 extern FILE *stdout;
97
98 /* printf_small() supports float print */
99 void printf_small (const char *fmt, ...);
100
101 /* printf_tiny() does not support float print */
102 void printf_tiny (const char *fmt, ...);  // __reentrant;
103
104 extern int printf (const char *fmt, ...);
105 extern int fprintf (FILE *stream, const char *fmt, ...);
106 extern int sprintf (char *str, const char *fmt, ...);
107
108 extern int vprintf (const char *fmt, va_list ap);
109 extern int vfprintf (FILE *stream, const char *fmt, va_list ap);
110 extern int vsprintf (char *str, const char *fmt, va_list ap);
111
112 extern void putchar (char c) __wparam;
113
114 extern void __stream_putchar (FILE *stream, char c);
115
116 extern void __stream_usart_putchar (char c) __wparam __naked;
117 extern void __stream_mssp_putchar (char c) __wparam __naked;
118 extern void __stream_gpsim_putchar (char c) __wparam __naked;
119
120 extern char *gets (char *str);
121 extern char getchar (void);
122
123 #endif /* __STDIO_H */