]> git.ozlabs.org Git - yaboot.git/blob - include/prom.h
546d082e4a26cf63c719b57895166ebd9b32f23a
[yaboot.git] / include / prom.h
1 /*
2     Definitions for talking to the Open Firmware PROM on
3     Power Macintosh computers.
4
5     Copyright (C) 1999 Marius Vollmer
6     Copyright (C) 1996 Paul Mackerras.
7
8     This program is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any 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, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 */
22
23 #ifndef PROM_H
24 #define PROM_H
25
26 #include "stdarg.h"
27
28 typedef void *prom_handle;
29 typedef void *ihandle;
30 typedef void *phandle;
31
32 #define PROM_INVALID_HANDLE     ((prom_handle)-1UL)
33
34 struct prom_args;
35 typedef int (*prom_entry)(struct prom_args *);
36
37 extern void prom_init (prom_entry pe);
38
39 extern prom_entry prom;
40
41 /* I/O */
42
43 extern prom_handle prom_stdin;
44 extern prom_handle prom_stdout;
45
46 prom_handle prom_open (char *spec);
47 int prom_read (prom_handle file, void *buf, int len);
48 int prom_write (prom_handle file, void *buf, int len);
49 int prom_seek (prom_handle file, int pos);
50 int prom_lseek (prom_handle file, unsigned long long pos);
51 int prom_readblocks (prom_handle file, int blockNum, int blockCount, void *buffer);
52 void prom_close (prom_handle file);
53 int prom_getblksize (prom_handle file);
54 int prom_loadmethod (prom_handle device, void* addr);
55
56 #define K_UP    0x141
57 #define K_DOWN  0x142
58 #define K_LEFT  0x144
59 #define K_RIGHT 0x143
60
61 int prom_getchar ();
62 void prom_putchar (char);
63 int prom_nbgetchar();
64
65 #ifdef __GNUC__
66 void prom_vprintf (char *fmt, va_list ap) __attribute__ ((format (printf, 1, 0)));
67 void prom_fprintf (prom_handle dev, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
68 void prom_printf (char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
69 #else
70 void prom_vprintf (char *fmt, va_list ap);
71 void prom_fprintf (prom_handle dev, char *fmt, ...);
72 void prom_printf (char *fmt, ...);
73 #endif
74
75 void prom_perror (int error, char *filename);
76 void prom_readline (char *prompt, char *line, int len);
77 int prom_set_color(prom_handle device, int color, int r, int g, int b);
78
79 /* memory */
80
81 void *prom_claim (void *virt, unsigned int size, unsigned int align);
82 void prom_release(void *virt, unsigned int size);
83 void prom_map (void *phys, void *virt, int size);
84
85 /* packages and device nodes */
86
87 prom_handle prom_finddevice (char *name);
88 prom_handle prom_findpackage (char *path);
89 int prom_getprop (prom_handle dev, char *name, void *buf, int len);
90
91 /* misc */
92
93 char *prom_getargs ();
94 void prom_setargs (char *args);
95
96 void prom_exit ();
97 void prom_abort (char *fmt, ...);
98 void prom_sleep (int seconds);
99
100 int prom_interpret (char *forth);
101
102 int prom_get_chosen (char *name, void *mem, int len);
103 int prom_get_options (char *name, void *mem, int len);
104
105 extern int prom_getms(void);
106 extern void prom_pause(void);
107
108 extern void *call_prom (const char *service, int nargs, int nret, ...);
109 extern void *call_prom_return (const char *service, int nargs, int nret, ...);
110
111 #endif