blob: 4c3f1ffc486d7afc725f43687c63f0f1138da5d0 [file] [log] [blame]
Kevin O'Connord25810a2008-06-12 22:16:35 -04001// 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'Connorb1b7c2a2009-01-15 20:52:58 -05006// This file may be distributed under the terms of the GNU LGPLv3 license.
Kevin O'Connord25810a2008-06-12 22:16:35 -04007
8#include "pci.h" // struct pir_header
9#include "util.h" // checksum
Kevin O'Connor9521e262008-07-04 13:04:29 -040010#include "biosvar.h" // SET_EBDA
Kevin O'Connord25810a2008-06-12 22:16:35 -040011
Kevin O'Connor372e0712009-09-09 09:51:31 -040012u16 PirOffset VAR16VISIBLE;
Kevin O'Connor51358db2008-12-28 21:50:29 -050013
Kevin O'Connord25810a2008-06-12 22:16:35 -040014struct pir_table {
15 struct pir_header pir;
16 struct pir_slot slots[6];
Kevin O'Connor51358db2008-12-28 21:50:29 -050017} PACKED;
18
19extern struct pir_table PIR_TABLE;
20#if CONFIG_PIRTABLE && !CONFIG_COREBOOT
Kevin O'Connorc0693942009-06-10 21:56:01 -040021struct pir_table PIR_TABLE __aligned(16) VAR16EXPORT = {
Kevin O'Connord25810a2008-06-12 22:16:35 -040022 .pir = {
Kevin O'Connord25810a2008-06-12 22:16:35 -040023 .version = 0x0100,
24 .size = sizeof(struct pir_table),
25 .router_devfunc = 0x08,
26 .compatible_devid = 0x122e8086,
Kevin O'Connord25810a2008-06-12 22:16:35 -040027 },
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'Connord25810a2008-06-12 22:16:35 -040091};
Kevin O'Connor51358db2008-12-28 21:50:29 -050092#endif // CONFIG_PIRTABLE && !CONFIG_COREBOOT
Kevin O'Connord25810a2008-06-12 22:16:35 -040093
94void
Kevin O'Connor1ca05b02010-01-03 17:43:37 -050095create_pirtable(void)
Kevin O'Connord25810a2008-06-12 22:16:35 -040096{
97 if (! CONFIG_PIRTABLE)
98 return;
99
Kevin O'Connor7b49cd92008-11-08 10:35:26 -0500100 dprintf(3, "init PIR table\n");
101
Kevin O'Connordb03d5d2008-06-21 11:55:29 -0400102 PIR_TABLE.pir.signature = PIR_SIGNATURE;
Kevin O'Connor523e5a92009-07-04 13:46:33 -0400103 PIR_TABLE.pir.checksum -= checksum(&PIR_TABLE, sizeof(PIR_TABLE));
Kevin O'Connor51358db2008-12-28 21:50:29 -0500104 PirOffset = (u32)&PIR_TABLE.pir - BUILD_BIOS_ADDR;
Kevin O'Connord25810a2008-06-12 22:16:35 -0400105}