pccard_cis.c (112358) | pccard_cis.c (119060) |
---|---|
1/* $NetBSD: pcmcia_cis.c,v 1.17 2000/02/10 09:01:52 chopps Exp $ */ | 1/* $NetBSD: pcmcia_cis.c,v 1.17 2000/02/10 09:01:52 chopps Exp $ */ |
2/* $FreeBSD: head/sys/dev/pccard/pccard_cis.c 112358 2003-03-18 02:38:33Z imp $ */ | 2/* $FreeBSD: head/sys/dev/pccard/pccard_cis.c 119060 2003-08-18 03:07:09Z imp $ */ |
3 4/* 5 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 119 unchanged lines hidden (view full) --- 130 return -1; 131 } 132 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, 133 rid, PCCARD_A_MEM_ATTR); 134 tuple.memt = rman_get_bustag(res); 135 tuple.memh = rman_get_bushandle(res); 136 tuple.ptr = 0; 137 | 3 4/* 5 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 119 unchanged lines hidden (view full) --- 130 return -1; 131 } 132 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, 133 rid, PCCARD_A_MEM_ATTR); 134 tuple.memt = rman_get_bustag(res); 135 tuple.memh = rman_get_bushandle(res); 136 tuple.ptr = 0; 137 |
138 DPRINTF(("cis mem map %x\n", (unsigned int) tuple.memh)); | 138 DPRINTF(("cis mem map 0x%x (resource: 0x%lx)\n", 139 (unsigned int) tuple.memh, rman_get_start(res))); |
139 140 tuple.mult = 2; 141 142 longlink_present = 1; 143 longlink_common = 1; 144 longlink_addr = 0; 145 146 mfc_count = 0; 147 mfc_index = 0; 148 149 DEVPRINTF((dev, "CIS tuple chain:\n")); 150 151 while (1) { 152 while (1) { | 140 141 tuple.mult = 2; 142 143 longlink_present = 1; 144 longlink_common = 1; 145 longlink_addr = 0; 146 147 mfc_count = 0; 148 mfc_index = 0; 149 150 DEVPRINTF((dev, "CIS tuple chain:\n")); 151 152 while (1) { 153 while (1) { |
153 /* get the tuple code */ | 154 /* 155 * Perform boundary check for insane cards. 156 * If CIS is too long, simulate CIS end. 157 * (This check may not be sufficient for 158 * malicious cards.) 159 */ 160 if (tuple.mult * tuple.ptr >= PCCARD_CIS_SIZE - 1 161 - 32 /* ad hoc value */ ) { 162 printf("CIS is too long -- truncating\n"); 163 tuple.code = PCCARD_CISTPL_END; 164 } else { 165 /* get the tuple code */ 166 tuple.code = pccard_cis_read_1(&tuple, tuple.ptr); 167 } |
154 | 168 |
155 tuple.code = pccard_cis_read_1(&tuple, tuple.ptr); 156 | |
157 /* two special-case tuples */ 158 159 if (tuple.code == PCCARD_CISTPL_NULL) { 160 DPRINTF(("CISTPL_NONE\n 00\n")); 161 tuple.ptr++; 162 continue; 163 } else if (tuple.code == PCCARD_CISTPL_END) { 164 DPRINTF(("CISTPL_END\n ff\n")); --- 191 unchanged lines hidden (view full) --- 356 357 /* 358 * the chain is done. Clean up and move onto the next one, 359 * if any. The loop is here in the case that there is an MFC 360 * card with no longlink (which defaults to existing, == 0). 361 * In general, this means that if one pointer fails, it will 362 * try the next one, instead of just bailing. 363 */ | 169 /* two special-case tuples */ 170 171 if (tuple.code == PCCARD_CISTPL_NULL) { 172 DPRINTF(("CISTPL_NONE\n 00\n")); 173 tuple.ptr++; 174 continue; 175 } else if (tuple.code == PCCARD_CISTPL_END) { 176 DPRINTF(("CISTPL_END\n ff\n")); --- 191 unchanged lines hidden (view full) --- 368 369 /* 370 * the chain is done. Clean up and move onto the next one, 371 * if any. The loop is here in the case that there is an MFC 372 * card with no longlink (which defaults to existing, == 0). 373 * In general, this means that if one pointer fails, it will 374 * try the next one, instead of just bailing. 375 */ |
364 | |
365 while (1) { 366 if (longlink_present) { 367 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, 368 SYS_RES_MEMORY, rid, longlink_common ? 369 PCCARD_A_MEM_COM : PCCARD_A_MEM_ATTR); 370 DPRINTF(("cis mem map %x\n", 371 (unsigned int) tuple.memh)); 372 tuple.mult = longlink_common ? 1 : 2; --- 900 unchanged lines hidden --- | 376 while (1) { 377 if (longlink_present) { 378 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, 379 SYS_RES_MEMORY, rid, longlink_common ? 380 PCCARD_A_MEM_COM : PCCARD_A_MEM_ATTR); 381 DPRINTF(("cis mem map %x\n", 382 (unsigned int) tuple.memh)); 383 tuple.mult = longlink_common ? 1 : 2; --- 900 unchanged lines hidden --- |