Deleted Added
full compact
isapnp.c (50477) isapnp.c (64187)
1/*
2 * Copyright (c) 1998, Michael Smith
3 * Copyright (c) 1996, Sujal M. Patel
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*
2 * Copyright (c) 1998, Michael Smith
3 * Copyright (c) 1996, Sujal M. Patel
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/boot/common/isapnp.c 50477 1999-08-28 01:08:13Z peter $
27 * $FreeBSD: head/sys/boot/common/isapnp.c 64187 2000-08-03 09:14:02Z jhb $
28 */
29
30/*
31 * Machine-independant ISA PnP enumerator implementing a subset of the
32 * ISA PnP specification.
33 */
34#include <stand.h>
35#include <string.h>
36#include <bootstrap.h>
37#include <isapnp.h>
38
39#define inb(x) (archsw.arch_isainb((x)))
40#define outb(x,y) (archsw.arch_isaoutb((x),(y)))
41
28 */
29
30/*
31 * Machine-independant ISA PnP enumerator implementing a subset of the
32 * ISA PnP specification.
33 */
34#include <stand.h>
35#include <string.h>
36#include <bootstrap.h>
37#include <isapnp.h>
38
39#define inb(x) (archsw.arch_isainb((x)))
40#define outb(x,y) (archsw.arch_isaoutb((x),(y)))
41
42static void isapnp_write(int d, u_char r);
43static u_char isapnp_read(int d);
44static void isapnp_send_Initiation_LFSR();
42static void isapnp_write(int d, int r);
43static void isapnp_send_Initiation_LFSR(void);
45static int isapnp_get_serial(u_int8_t *p);
46static int isapnp_isolation_protocol(void);
47static void isapnp_enumerate(void);
48
49/* PnP read data port */
50int isapnp_readport = 0;
51
52#define _PNP_ID_LEN 9
53
54struct pnphandler isapnphandler =
55{
56 "ISA bus",
57 isapnp_enumerate
58};
59
60static void
44static int isapnp_get_serial(u_int8_t *p);
45static int isapnp_isolation_protocol(void);
46static void isapnp_enumerate(void);
47
48/* PnP read data port */
49int isapnp_readport = 0;
50
51#define _PNP_ID_LEN 9
52
53struct pnphandler isapnphandler =
54{
55 "ISA bus",
56 isapnp_enumerate
57};
58
59static void
61isapnp_write(int d, u_char r)
60isapnp_write(int d, int r)
62{
63 outb (_PNP_ADDRESS, d);
64 outb (_PNP_WRITE_DATA, r);
65}
66
61{
62 outb (_PNP_ADDRESS, d);
63 outb (_PNP_WRITE_DATA, r);
64}
65
67static u_char
68isapnp_read(int d)
69{
70 outb (_PNP_ADDRESS, d);
71 return (inb(isapnp_readport));
72}
73
74/*
75 * Send Initiation LFSR as described in "Plug and Play ISA Specification",
76 * Intel May 94.
77 */
78static void
66/*
67 * Send Initiation LFSR as described in "Plug and Play ISA Specification",
68 * Intel May 94.
69 */
70static void
79isapnp_send_Initiation_LFSR()
71isapnp_send_Initiation_LFSR(void)
80{
81 int cur, i;
82
83 /* Reset the LSFR */
84 outb(_PNP_ADDRESS, 0);
85 outb(_PNP_ADDRESS, 0); /* yes, we do need it twice! */
86
87 cur = 0x6a;

--- 74 unchanged lines hidden (view full) ---

162 * and assume it's for the card as a whole.
163 *
164 * Returns 0 if the scan completed OK, nonzero on error.
165 */
166static int
167isapnp_scan_resdata(struct pnpinfo *pi)
168{
169 u_char tag, resinfo[8];
72{
73 int cur, i;
74
75 /* Reset the LSFR */
76 outb(_PNP_ADDRESS, 0);
77 outb(_PNP_ADDRESS, 0); /* yes, we do need it twice! */
78
79 cur = 0x6a;

--- 74 unchanged lines hidden (view full) ---

154 * and assume it's for the card as a whole.
155 *
156 * Returns 0 if the scan completed OK, nonzero on error.
157 */
158static int
159isapnp_scan_resdata(struct pnpinfo *pi)
160{
161 u_char tag, resinfo[8];
170 int large_len, limit;
171 char *str;
162 u_int limit;
163 size_t large_len;
164 u_char *str;
172
173 limit = 1000;
174 while ((limit-- > 0) && !isapnp_get_resource_info(&tag, 1)) {
175 if (PNP_RES_TYPE(tag) == 0) {
176 /* Small resource */
177 switch (PNP_SRES_NUM(tag)) {
178
179 case COMP_DEVICE_ID:

--- 19 unchanged lines hidden (view full) ---

199
200 large_len = resinfo[1];
201 large_len = (large_len << 8) + resinfo[0];
202
203 switch(PNP_LRES_NUM(tag)) {
204
205 case ID_STRING_ANSI:
206 str = malloc(large_len + 1);
165
166 limit = 1000;
167 while ((limit-- > 0) && !isapnp_get_resource_info(&tag, 1)) {
168 if (PNP_RES_TYPE(tag) == 0) {
169 /* Small resource */
170 switch (PNP_SRES_NUM(tag)) {
171
172 case COMP_DEVICE_ID:

--- 19 unchanged lines hidden (view full) ---

192
193 large_len = resinfo[1];
194 large_len = (large_len << 8) + resinfo[0];
195
196 switch(PNP_LRES_NUM(tag)) {
197
198 case ID_STRING_ANSI:
199 str = malloc(large_len + 1);
207 if (isapnp_get_resource_info(str, large_len)) {
200 if (isapnp_get_resource_info(str, (ssize_t)large_len)) {
208 free(str);
209 return(1);
210 }
211 str[large_len] = 0;
212 if (pi->pi_desc == NULL) {
201 free(str);
202 return(1);
203 }
204 str[large_len] = 0;
205 if (pi->pi_desc == NULL) {
213 pi->pi_desc = str;
206 pi->pi_desc = (char *)str;
214 } else {
215 free(str);
216 }
217 break;
218
219 default:
220 /* Large resource, skip it */
207 } else {
208 free(str);
209 }
210 break;
211
212 default:
213 /* Large resource, skip it */
221 if (isapnp_get_resource_info(NULL, large_len))
214 if (isapnp_get_resource_info(NULL, (ssize_t)large_len))
222 return(1);
223 }
224 }
225 }
226 return(1);
227}
228
229/*

--- 90 unchanged lines hidden ---
215 return(1);
216 }
217 }
218 }
219 return(1);
220}
221
222/*

--- 90 unchanged lines hidden ---