1 /* 2 * pir.c: Support for genrating $PIR tables. 3 * 4 * Copyright (c) 2011 Citrix Systems Inc 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms and conditions of the GNU General Public License, 8 * version 2, as published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 * more details. 14 */ 15 16 #include "config.h" 17 #include "pir_types.h" 18 #include "util.h" 19 20 /* 21 * The structure of these tables is described in 22 * http://www.microsoft.com/taiwan/whdc/archive/pciirq.mspx 23 */ create_pir_tables(void)24unsigned long create_pir_tables(void) 25 { 26 int length = sizeof(struct pir_table) 27 + sizeof(struct pir_slot) * NR_PIR_SLOTS; 28 struct pir_table *pir = scratch_alloc(length, 0); 29 int i, checksum; 30 31 memset(pir, 0, length); 32 33 memcpy(pir->signature, "$PIR", 4); 34 pir->version = 0x0100; 35 pir->length = length; 36 37 pir->router_bus = 0; 38 pir->router_devfn = PCI_ISA_DEVFN; 39 pir->router_vid = 0x8086; 40 pir->router_did = 0x122e; 41 42 pir->pci_irqs = 0x0000; 43 44 for ( i = 0 ; i < NR_PIR_SLOTS; i++ ) 45 { 46 struct pir_slot *slot = &pir->slots[i]; 47 slot->slot = i; 48 slot->bus = 0; 49 slot->dev = i<<3; 50 slot->link_a = 0x60 + (i+1)%4; 51 slot->bitmap_a = PCI_ISA_IRQ_MASK; 52 slot->link_b = 0x60 + (i+2)%4; 53 slot->bitmap_b = PCI_ISA_IRQ_MASK; 54 slot->link_c = 0x60 + (i+3)%4; 55 slot->bitmap_c = PCI_ISA_IRQ_MASK; 56 slot->link_d = 0x60 + (i+4)%4; 57 slot->bitmap_d = PCI_ISA_IRQ_MASK; 58 } 59 60 checksum = 0; 61 for ( i = 0; i < length; i++ ) 62 checksum += ((int8_t *)pir)[i]; 63 pir->checksum = -checksum; 64 65 return (unsigned long)pir; 66 } 67 68 /* 69 * Local variables: 70 * mode: C 71 * c-file-style: "BSD" 72 * c-basic-offset: 4 73 * tab-width: 4 74 * indent-tabs-mode: nil 75 * End: 76 */ 77