29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/types.h>
33 #include <linux/slab.h>
35 #include <linux/pci.h>
38 #include <asm/uaccess.h>
43 #define ROM_INT15_PHY_ADDR 0x0FF859
44 #define READ_EV 0xD8A4
45 #define WRITE_EV 0xD8A5
91 static u8 evbuffer_init;
92 static u8 evbuffer_length;
93 static u8 evbuffer[1024];
95 static void __iomem *compaq_int15_entry_point;
115 if ((*used + 1) > *avail)
119 tByte = (
u8**)p_buffer;
128 if ((*used + 4) > *avail)
145 static int check_for_compaq_ROM (
void __iomem *rom_start)
150 temp1 =
readb(rom_start + 0xffea + 0);
151 temp2 =
readb(rom_start + 0xffea + 1);
152 temp3 =
readb(rom_start + 0xffea + 2);
153 temp4 =
readb(rom_start + 0xffea + 3);
154 temp5 =
readb(rom_start + 0xffea + 4);
155 temp6 =
readb(rom_start + 0xffea + 5);
156 if ((temp1 ==
'C') &&
164 dbg (
"%s - returned %d\n", __func__, result);
175 if (!compaq_int15_entry_point)
180 "xorl %%ebx,%%ebx\n" \
181 "xorl %%edx,%%edx\n" \
186 :
"=c" (*buf_size),
"=a" (ret_val)
187 :
"a" (op),
"c" (*buf_size),
"S" (ev_name),
188 "D" (buffer),
"m" (compaq_int15_entry_point)
190 spin_unlock_irqrestore(&int15_lock, flags);
192 return((ret_val & 0xFF00) >> 8);
201 static int load_HRT (
void __iomem *rom_start)
208 if (!check_for_compaq_ROM(rom_start)) {
217 rc = access_EV(
READ_EV,
"CQTHPS", evbuffer, &temp_dword);
219 evbuffer_length = temp_dword;
226 rc = access_EV(
WRITE_EV,
"CQTHPS", &temp_byte, &temp_dword);
237 static u32 store_HRT (
void __iomem *rom_start)
254 if (!check_for_compaq_ROM(rom_start)) {
258 buffer = (
u32*) evbuffer;
271 rc = add_byte( &pFill, 1 + ctrl->
push_flag, &usedbytes, &available);
276 rc = add_byte( &pFill, 1, &usedbytes, &available);
286 rc = add_byte( &pFill, ctrl->
bus, &usedbytes, &available);
291 rc = add_byte( &pFill,
PCI_SLOT(ctrl->
pci_dev->devfn), &usedbytes, &available);
296 rc = add_byte( &pFill,
PCI_FUNC(ctrl->
pci_dev->devfn), &usedbytes, &available);
301 rc = add_dword( &pFill, 0, &usedbytes, &available);
315 rc = add_dword( &pFill, resNode->
base, &usedbytes, &available);
320 rc = add_dword( &pFill, resNode->
length, &usedbytes, &available);
324 resNode = resNode->
next;
340 rc = add_dword( &pFill, resNode->
base, &usedbytes, &available);
345 rc = add_dword( &pFill, resNode->
length, &usedbytes, &available);
349 resNode = resNode->
next;
365 rc = add_dword( &pFill, resNode->
base, &usedbytes, &available);
370 rc = add_dword( &pFill, resNode->
length, &usedbytes, &available);
374 resNode = resNode->
next;
390 rc = add_dword( &pFill, resNode->
base, &usedbytes, &available);
395 rc = add_dword( &pFill, resNode->
length, &usedbytes, &available);
399 resNode = resNode->
next;
412 temp_dword = usedbytes;
414 rc = access_EV(
WRITE_EV,
"CQTHPS", (
u8*) buffer, &temp_dword);
416 dbg(
"usedbytes = 0x%x, length = 0x%x\n", usedbytes, temp_dword);
418 evbuffer_length = temp_dword;
434 dbg(
"int15 entry = %p\n", compaq_int15_entry_point);
444 u8 nummem, numpmem, numio, numbus;
454 if (!evbuffer_init) {
456 if (load_HRT(rom_start))
457 memset (evbuffer, 0, 1024);
470 if ((p_EV_header->
Version == 2) ||
472 p_byte = &(p_EV_header->
next);
478 if (p_byte > ((
u8*)p_EV_header + evbuffer_length))
481 bus = p_ev_ctrl->
bus;
482 device = p_ev_ctrl->
device;
485 while ((bus != ctrl->
bus) ||
495 if (p_byte > ((
u8*)p_EV_header + evbuffer_length))
499 p_byte += (nummem + numpmem + numio + numbus) * 8;
501 if (p_byte > ((
u8*)p_EV_header + evbuffer_length))
508 if (p_byte > ((
u8*)p_EV_header + evbuffer_length))
511 bus = p_ev_ctrl->
bus;
512 device = p_ev_ctrl->
device;
523 if (p_byte > ((
u8*)p_EV_header + evbuffer_length))
532 mem_node->
base = *(
u32*)p_byte;
533 dbg(
"mem base = %8.8x\n",mem_node->
base);
536 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
542 dbg(
"mem length = %8.8x\n",mem_node->
length);
545 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
560 p_mem_node->
base = *(
u32*)p_byte;
561 dbg(
"pre-mem base = %8.8x\n",p_mem_node->
base);
564 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
570 dbg(
"pre-mem length = %8.8x\n",p_mem_node->
length);
573 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
589 dbg(
"io base = %8.8x\n",io_node->
base);
592 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
598 dbg(
"io length = %8.8x\n",io_node->
length);
601 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
616 bus_node->
base = *(
u32*)p_byte;
619 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
627 if (p_byte > ((
u8*)p_EV_header + evbuffer_length)) {
648 if ((evbuffer[0] != 0) && (!ctrl->
push_flag))
660 if (rom_start ==
NULL)
664 rc = store_HRT(rom_start);