Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 1 | // PIR table generation (for emulators) |
| 2 | // |
| 3 | // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net> |
| 4 | // Copyright (C) 2002 MandrakeSoft S.A. |
| 5 | // |
Kevin O'Connor | b1b7c2a | 2009-01-15 20:52:58 -0500 | [diff] [blame] | 6 | // This file may be distributed under the terms of the GNU LGPLv3 license. |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 7 | |
| 8 | #include "pci.h" // struct pir_header |
| 9 | #include "util.h" // checksum |
Kevin O'Connor | 9521e26 | 2008-07-04 13:04:29 -0400 | [diff] [blame] | 10 | #include "biosvar.h" // SET_EBDA |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 11 | |
Kevin O'Connor | 92f95b0 | 2008-12-29 20:42:40 -0500 | [diff] [blame] | 12 | u16 PirOffset VAR16_32; |
Kevin O'Connor | 51358db | 2008-12-28 21:50:29 -0500 | [diff] [blame] | 13 | |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 14 | struct pir_table { |
| 15 | struct pir_header pir; |
| 16 | struct pir_slot slots[6]; |
Kevin O'Connor | 51358db | 2008-12-28 21:50:29 -0500 | [diff] [blame] | 17 | } PACKED; |
| 18 | |
| 19 | extern struct pir_table PIR_TABLE; |
| 20 | #if CONFIG_PIRTABLE && !CONFIG_COREBOOT |
Kevin O'Connor | c069394 | 2009-06-10 21:56:01 -0400 | [diff] [blame] | 21 | struct pir_table PIR_TABLE __aligned(16) VAR16EXPORT = { |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 22 | .pir = { |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 23 | .version = 0x0100, |
| 24 | .size = sizeof(struct pir_table), |
| 25 | .router_devfunc = 0x08, |
| 26 | .compatible_devid = 0x122e8086, |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 27 | }, |
| 28 | .slots = { |
| 29 | { |
| 30 | // first slot entry PCI-to-ISA (embedded) |
| 31 | .dev = 1<<3, |
| 32 | .links = { |
| 33 | {.link = 0x60, .bitmap = 0xdef8}, // INTA# |
| 34 | {.link = 0x61, .bitmap = 0xdef8}, // INTB# |
| 35 | {.link = 0x62, .bitmap = 0xdef8}, // INTC# |
| 36 | {.link = 0x63, .bitmap = 0xdef8}, // INTD# |
| 37 | }, |
| 38 | .slot_nr = 0, // embedded |
| 39 | }, { |
| 40 | // second slot entry: 1st PCI slot |
| 41 | .dev = 2<<3, |
| 42 | .links = { |
| 43 | {.link = 0x61, .bitmap = 0xdef8}, // INTA# |
| 44 | {.link = 0x62, .bitmap = 0xdef8}, // INTB# |
| 45 | {.link = 0x63, .bitmap = 0xdef8}, // INTC# |
| 46 | {.link = 0x60, .bitmap = 0xdef8}, // INTD# |
| 47 | }, |
| 48 | .slot_nr = 1, |
| 49 | }, { |
| 50 | // third slot entry: 2nd PCI slot |
| 51 | .dev = 3<<3, |
| 52 | .links = { |
| 53 | {.link = 0x62, .bitmap = 0xdef8}, // INTA# |
| 54 | {.link = 0x63, .bitmap = 0xdef8}, // INTB# |
| 55 | {.link = 0x60, .bitmap = 0xdef8}, // INTC# |
| 56 | {.link = 0x61, .bitmap = 0xdef8}, // INTD# |
| 57 | }, |
| 58 | .slot_nr = 2, |
| 59 | }, { |
| 60 | // 4th slot entry: 3rd PCI slot |
| 61 | .dev = 4<<3, |
| 62 | .links = { |
| 63 | {.link = 0x63, .bitmap = 0xdef8}, // INTA# |
| 64 | {.link = 0x60, .bitmap = 0xdef8}, // INTB# |
| 65 | {.link = 0x61, .bitmap = 0xdef8}, // INTC# |
| 66 | {.link = 0x62, .bitmap = 0xdef8}, // INTD# |
| 67 | }, |
| 68 | .slot_nr = 3, |
| 69 | }, { |
| 70 | // 5th slot entry: 4rd PCI slot |
| 71 | .dev = 5<<3, |
| 72 | .links = { |
| 73 | {.link = 0x60, .bitmap = 0xdef8}, // INTA# |
| 74 | {.link = 0x61, .bitmap = 0xdef8}, // INTB# |
| 75 | {.link = 0x62, .bitmap = 0xdef8}, // INTC# |
| 76 | {.link = 0x63, .bitmap = 0xdef8}, // INTD# |
| 77 | }, |
| 78 | .slot_nr = 4, |
| 79 | }, { |
| 80 | // 6th slot entry: 5rd PCI slot |
| 81 | .dev = 6<<3, |
| 82 | .links = { |
| 83 | {.link = 0x61, .bitmap = 0xdef8}, // INTA# |
| 84 | {.link = 0x62, .bitmap = 0xdef8}, // INTB# |
| 85 | {.link = 0x63, .bitmap = 0xdef8}, // INTC# |
| 86 | {.link = 0x60, .bitmap = 0xdef8}, // INTD# |
| 87 | }, |
| 88 | .slot_nr = 5, |
| 89 | }, |
| 90 | } |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 91 | }; |
Kevin O'Connor | 51358db | 2008-12-28 21:50:29 -0500 | [diff] [blame] | 92 | #endif // CONFIG_PIRTABLE && !CONFIG_COREBOOT |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 93 | |
| 94 | void |
| 95 | create_pirtable() |
| 96 | { |
| 97 | if (! CONFIG_PIRTABLE) |
| 98 | return; |
| 99 | |
Kevin O'Connor | 7b49cd9 | 2008-11-08 10:35:26 -0500 | [diff] [blame] | 100 | dprintf(3, "init PIR table\n"); |
| 101 | |
Kevin O'Connor | db03d5d | 2008-06-21 11:55:29 -0400 | [diff] [blame] | 102 | PIR_TABLE.pir.signature = PIR_SIGNATURE; |
Kevin O'Connor | 523e5a9 | 2009-07-04 13:46:33 -0400 | [diff] [blame^] | 103 | PIR_TABLE.pir.checksum -= checksum(&PIR_TABLE, sizeof(PIR_TABLE)); |
Kevin O'Connor | 51358db | 2008-12-28 21:50:29 -0500 | [diff] [blame] | 104 | PirOffset = (u32)&PIR_TABLE.pir - BUILD_BIOS_ADDR; |
Kevin O'Connor | d25810a | 2008-06-12 22:16:35 -0400 | [diff] [blame] | 105 | } |