]> git.ozlabs.org Git - yaboot.git/blob - include/prom.h
Add support to ofpath for usb-storage and fix sbp-2 storage
[yaboot.git] / include / prom.h
1 /*
2  *  prom.h - Routines for talking to the Open Firmware PROM
3  *
4  *  Copyright (C) 2001 Ethan Benson
5  *
6  *  Copyright (C) 1999 Benjamin Herrenschmidt
7  *
8  *  Copyright (C) 1999 Marius Vollmer
9  *
10  *  Copyright (C) 1996 Paul Mackerras.
11  *
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef PROM_H
28 #define PROM_H
29
30 #include "stdarg.h"
31
32 typedef void *prom_handle;
33 typedef void *ihandle;
34 typedef void *phandle;
35
36 #define PROM_INVALID_HANDLE     ((prom_handle)-1UL)
37
38 struct prom_args;
39 typedef int (*prom_entry)(struct prom_args *);
40
41 extern void prom_init (prom_entry pe);
42
43 extern prom_entry prom;
44
45 /* I/O */
46
47 extern prom_handle prom_stdin;
48 extern prom_handle prom_stdout;
49
50 prom_handle prom_open (char *spec);
51 int prom_read (prom_handle file, void *buf, int len);
52 int prom_write (prom_handle file, void *buf, int len);
53 int prom_seek (prom_handle file, int pos);
54 int prom_lseek (prom_handle file, unsigned long long pos);
55 int prom_readblocks (prom_handle file, int blockNum, int blockCount, void *buffer);
56 void prom_close (prom_handle file);
57 int prom_getblksize (prom_handle file);
58 int prom_loadmethod (prom_handle device, void* addr);
59
60 #define K_UP    0x141
61 #define K_DOWN  0x142
62 #define K_LEFT  0x144
63 #define K_RIGHT 0x143
64
65 int prom_getchar ();
66 void prom_putchar (char);
67 int prom_nbgetchar();
68
69 #ifdef __GNUC__
70 void prom_vprintf (char *fmt, va_list ap) __attribute__ ((format (printf, 1, 0)));
71 void prom_fprintf (prom_handle dev, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
72 void prom_printf (char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
73 #else
74 void prom_vprintf (char *fmt, va_list ap);
75 void prom_fprintf (prom_handle dev, char *fmt, ...);
76 void prom_printf (char *fmt, ...);
77 #endif
78
79 void prom_perror (int error, char *filename);
80 void prom_readline (char *prompt, char *line, int len);
81 int prom_set_color(prom_handle device, int color, int r, int g, int b);
82
83 /* memory */
84
85 void *prom_claim (void *virt, unsigned int size, unsigned int align);
86 void prom_release(void *virt, unsigned int size);
87 void prom_map (void *phys, void *virt, int size);
88
89 /* packages and device nodes */
90
91 prom_handle prom_finddevice (char *name);
92 prom_handle prom_findpackage (char *path);
93 int prom_getprop (prom_handle dev, char *name, void *buf, int len);
94 int prom_get_devtype (char *device);
95
96 /* misc */
97
98 char *prom_getargs ();
99 void prom_setargs (char *args);
100
101 void prom_exit ();
102 void prom_abort (char *fmt, ...);
103 void prom_sleep (int seconds);
104
105 int prom_interpret (char *forth);
106
107 int prom_get_chosen (char *name, void *mem, int len);
108 int prom_get_options (char *name, void *mem, int len);
109
110 extern int prom_getms(void);
111 extern void prom_pause(void);
112
113 extern void *call_prom (const char *service, int nargs, int nret, ...);
114 extern void *call_prom_return (const char *service, int nargs, int nret, ...);
115
116 #endif