2 * prom.h - Routines for talking to the Open Firmware PROM
4 * Copyright (C) 2001 Ethan Benson
6 * Copyright (C) 1999 Benjamin Herrenschmidt
8 * Copyright (C) 1999 Marius Vollmer
10 * Copyright (C) 1996 Paul Mackerras.
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.
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.
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.
33 typedef void *prom_handle;
34 typedef void *ihandle;
35 typedef void *phandle;
37 #define PROM_INVALID_HANDLE ((prom_handle)-1UL)
38 #define BOOTDEVSZ (2048) /* iscsi args can be in excess of 1040 bytes */
39 #define TOK_ISCSI "iscsi"
40 #define PROM_CLAIM_MAX_ADDR 0x8000000
43 typedef int (*prom_entry)(struct prom_args *);
45 extern void prom_init (prom_entry pe);
47 extern prom_entry prom;
51 extern prom_handle prom_stdin;
52 extern prom_handle prom_stdout;
54 prom_handle prom_open (char *spec);
55 int prom_read (prom_handle file, void *buf, int len);
56 int prom_write (prom_handle file, void *buf, int len);
57 int prom_seek (prom_handle file, int pos);
58 int prom_lseek (prom_handle file, unsigned long long pos);
59 int prom_readblocks (prom_handle file, int blockNum, int blockCount, void *buffer);
60 void prom_close (prom_handle file);
61 int prom_getblksize (prom_handle file);
62 int prom_loadmethod (prom_handle device, void* addr);
70 void prom_putchar (char);
74 void prom_vprintf (char *fmt, va_list ap) __attribute__ ((format (printf, 1, 0)));
75 void prom_fprintf (prom_handle dev, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
76 void prom_printf (char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
78 void prom_vprintf (char *fmt, va_list ap);
79 void prom_fprintf (prom_handle dev, char *fmt, ...);
80 void prom_printf (char *fmt, ...);
83 void prom_perror (int error, char *filename);
84 void prom_readline (char *prompt, char *line, int len);
85 int prom_set_color(prom_handle device, int color, int r, int g, int b);
89 void *prom_claim_chunk(void *virt, unsigned int size, unsigned int align);
90 void *prom_claim (void *virt, unsigned int size, unsigned int align);
91 void prom_release(void *virt, unsigned int size);
92 void prom_map (void *phys, void *virt, int size);
94 /* packages and device nodes */
96 prom_handle prom_finddevice (char *name);
97 prom_handle prom_findpackage (char *path);
98 int prom_getprop (prom_handle dev, char *name, void *buf, int len);
99 int prom_setprop (prom_handle dev, char *name, void *buf, int len);
100 int prom_getproplen(prom_handle, const char *);
101 int prom_get_devtype (char *device);
105 char *prom_getargs ();
106 void prom_setargs (char *args);
109 void prom_abort (char *fmt, ...);
110 void prom_sleep (int seconds);
112 int prom_interpret (char *forth);
114 int prom_get_chosen (char *name, void *mem, int len);
115 int prom_get_options (char *name, void *mem, int len);
116 int prom_set_options (char *name, void *mem, int len);
118 extern int prom_getms(void);
119 extern void prom_pause(void);
121 extern void *call_prom (const char *service, int nargs, int nret, ...);
122 extern void *call_prom_return (const char *service, int nargs, int nret, ...);
127 * "bootp-response" is the property name which is specified in
128 * the recommended practice doc for obp-tftp. However, pmac
129 * provides a "dhcp-response" property and chrp provides a
130 * "bootpreply-packet" property. The latter appears to begin the
131 * bootp packet at offset 0x2a in the property for some reason.
134 struct bootp_property_offset {
135 char *name; /* property name */
136 int offset; /* offset into property where bootp packet occurs */
139 static const struct bootp_property_offset bootp_response_properties[] = {
140 { .name = "bootp-response", .offset = 0 },
141 { .name = "dhcp-response", .offset = 0 },
142 { .name = "bootpreply-packet", .offset = 0x2a },
145 struct bootp_packet {
146 __u8 op, htype, hlen, hops;
149 __u32 ciaddr, yiaddr, siaddr, giaddr;
150 unsigned char chaddr[16];
151 unsigned char sname[64];
152 unsigned char file[128];
153 /* vendor options go here if we need them */
156 struct bootp_packet * prom_get_netinfo (void);
157 char * prom_get_mac (struct bootp_packet * packet);
158 char * prom_get_ip (struct bootp_packet * packet);