add shared files git-svn-id: svn://coreboot.org/openbios/fcode-utils@77 f158a5a8-5612-0410-a976-696ce0be7e32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0e42454
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+#
+# OpenBIOS - free your system!
+# ( Utilities )
+#
+# This program is part of a free implementation of the IEEE 1275-1994
+# Standard for Boot (Initialization Configuration) Firmware.
+#
+# Copyright (C) 2006 coresystems GmbH <info@coresystems.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+#
+
+all:
+ make -C toke
+ make -C detok
+ make -C romheaders
+
+install:
+ make -C toke install
+ make -C detok install
+ make -C romheaders install
+
+clean:
+ make -C toke clean
+ make -C detok clean
+ make -C romheaders clean
+
+distclean: clean
+ make -C toke distclean
+ make -C detok distclean
+ make -C romheaders distclean
+
+
+
+.PHONY: all clean distclean toke detok romheaders
+
diff --git a/shared/classcodes.c b/shared/classcodes.c
new file mode 100644
index 0000000..74a6d11
--- /dev/null
+++ b/shared/classcodes.c
@@ -0,0 +1,415 @@
+/*
+ * OpenBIOS - free your system!
+ * ( FCode tokenizer )
+ *
+ * This program is part of a free implementation of the IEEE 1275-1994
+ * Standard for Boot (Initialization Configuration) Firmware.
+ *
+ * Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ *
+ */
+
+/* **************************************************************************
+ *
+ * Functions to correlate PCI Device Class-Codes and PCI Code Types
+ * with their printable names.
+ *
+ * (C) Copyright 2005 IBM Corporation. All Rights Reserved.
+ * Module Author: David L. Paktor dlpaktor@us.ibm.com
+ *
+ **************************************************************************** */
+
+#include <stdlib.h>
+#include "types.h"
+
+/* **************************************************************************
+ *
+ * Functions Eported:
+ * pci_device_class_name
+ * Convert a numeric PCI Class Code to the Device Class Name
+ *
+ * pci_code_type_name
+ * Convert a numeric PCI Code Type to a printable Name
+ *
+ **************************************************************************** */
+
+const char *pci_device_class_name( u32 code);
+const char *pci_code_type_name(u8 code);
+
+
+typedef struct {
+ const u32 classcode;
+ const char *classname;
+} num_to_name_table ;
+
+
+/* **************************************************************************
+ *
+ * Function name: convert_num_to_name
+ * Synopsis: Find the Name, in the given table, for the given Number.
+ * Support function for Exported Functions.
+ *
+ * Inputs:
+ * Parameters:
+ * u32 num Number to look up
+ * num_to_name_table *table Pointer to Table to scan
+ * int max Maximum Index of Table
+ * char *not_found String to return if Number not in Table
+ *
+ * Outputs:
+ * Returned Value: Pointer to string giving the Name
+ *
+ * Error Detection:
+ * Unrecognized Number
+ * Return "not_found" string
+ *
+ * Process Explanation:
+ * Scan the Table for a match.
+ *
+ * Still to be done / Misc remarks:
+ * Had been considering a more sophisticated binary search,
+ * but the database is too small to merit the extra code.
+ * Stayed with the KISS principle...
+ *
+ *
+ **************************************************************************** */
+
+static const char *convert_num_to_name(u32 num,
+ num_to_name_table *table,
+ int max,
+ const char *not_found)
+{
+ int indx;
+ const char *retval;
+
+ retval = not_found;
+
+ for (indx = 0; indx < max ; indx++)
+ {
+ if ( num == table[indx].classcode )
+ {
+ retval = table[indx].classname ;
+ break ;
+ }
+ }
+ return ( retval );
+}
+
+
+/* **************************************************************************
+ *
+ *
+ * Structures:
+ * pci_code_type_name_table Constant Data Table that correlates
+ * PCI Code Types with their Names.
+ *
+ * pci_dev_class_name_table Constant Data Table that correlates
+ * Class Codes with their Class Names.
+ * This list of codes and names is current
+ * as of PCI Local Bus Specification
+ * Revision 3.0 dated February 3, 2004
+ *
+ **************************************************************************** */
+
+
+static const num_to_name_table pci_code_type_name_table[] = {
+ { 0 , "Intel x86" },
+ { 1 , "Open Firmware" },
+ { 2 , "HP PA Risc" },
+ { 3 , "Intel EFI (unofficial)" }
+};
+
+
+static const num_to_name_table pci_dev_class_name_table[] = {
+ { 0x000000 , "Legacy Device" },
+ { 0x000100 , "VGA-Compatible Device" },
+
+ { 0x010000 , "SCSI bus controller" },
+ /* { 0x0101xx , "IDE controller" }, */
+ { 0x010200 , "Floppy disk controller" },
+ { 0x010300 , "IPI bus controller" },
+ { 0x010400 , "RAID controller" },
+ { 0x010520 , "ATA controller, single stepping" },
+ { 0x010530 , "ATA controller, continuous" },
+ { 0x010600 , "Serial ATA controller - vendor specific interface" },
+ { 0x010601 , "Serial ATA controller - AHCI 1.0 interface" },
+ { 0x010700 , "Serial Attached SCSI controller" },
+ { 0x018000 , "Mass Storage controller" },
+
+ { 0x020000 , "Ethernet controller" },
+ { 0x020100 , "Token Ring controller" },
+ { 0x020200 , "FDDI controller" },
+ { 0x020300 , "ATM controller" },
+ { 0x020400 , "ISDN controller" },
+ { 0x020500 , "WorldFip controller" },
+ /* { 0x0206xx , "PICMG 2.14 Multi Computing" }, */
+ { 0x028000 , "Network controller" },
+
+ { 0x030000 , "VGA Display controller" },
+ { 0x030001 , "8514-compatible Display controller" },
+ { 0x030100 , "XGA Display controller" },
+ { 0x030200 , "3D Display controller" },
+ { 0x038000 , "Display controller" },
+
+ { 0x040000 , "Video device" },
+ { 0x040100 , "Audio device" },
+ { 0x040200 , "Computer Telephony device" },
+ { 0x048000 , "Multimedia device" },
+
+ { 0x050000 , "RAM memory controller" },
+ { 0x050100 , "Flash memory controller" },
+ { 0x058000 , "Memory controller" },
+
+ { 0x060000 , "Host bridge" },
+ { 0x060100 , "ISA bridge" },
+ { 0x060200 , "EISA bridge" },
+ { 0x060300 , "MCA bridge" },
+ { 0x060400 , "PCI-to-PCI bridge" },
+ { 0x060401 , "PCI-to-PCI bridge (subtractive decoding)" },
+ { 0x060500 , "PCMCIA bridge" },
+ { 0x060600 , "NuBus bridge" },
+ { 0x060700 , "CardBus bridge" },
+ /* { 0x0608xx , "RACEway bridge" }, */
+ { 0x060940 , "PCI-to-PCI bridge, Semi-transparent, primary facing Host" },
+ { 0x060980 , "PCI-to-PCI bridge, Semi-transparent, secondary facing Host" },
+ { 0x060A00 , "InfiniBand-to-PCI host bridge" },
+ { 0x068000 , "Bridge device" },
+
+ { 0x070000 , "Generic XT-compatible serial controller" },
+ { 0x070001 , "16450-compatible serial controller" },
+ { 0x070002 , "16550-compatible serial controller" },
+ { 0x070003 , "16650-compatible serial controller" },
+ { 0x070004 , "16750-compatible serial controller" },
+ { 0x070005 , "16850-compatible serial controller" },
+ { 0x070006 , "16950-compatible serial controller" },
+
+ { 0x070100 , "Parallel port" },
+ { 0x070101 , "Bi-directional parallel port" },
+ { 0x070102 , "ECP 1.X compliant parallel port" },
+ { 0x070103 , "IEEE1284 controller" },
+ { 0x0701FE , "IEEE1284 target device" },
+ { 0x070200 , "Multiport serial controller" },
+
+ { 0x070300 , "Generic modem" },
+ { 0x070301 , "Hayes 16450-compatible modem" },
+ { 0x070302 , "Hayes 16550-compatible modem" },
+ { 0x070303 , "Hayes 16650-compatible modem" },
+ { 0x070304 , "Hayes 16750-compatible modem" },
+ { 0x070400 , "GPIB (IEEE 488.1/2) controller" },
+ { 0x070500 , "Smart Card" },
+ { 0x078000 , "Communications device" },
+
+ { 0x080000 , "Generic 8259 PIC" },
+ { 0x080001 , "ISA PIC" },
+ { 0x080002 , "EISA PIC" },
+ { 0x080010 , "I/O APIC interrupt controller" },
+ { 0x080020 , "I/O(x) APIC interrupt controller" },
+
+ { 0x080100 , "Generic 8237 DMA controller" },
+ { 0x080101 , "ISA DMA controller" },
+ { 0x080102 , "EISA DMA controller" },
+
+ { 0x080200 , "Generic 8254 system timer" },
+ { 0x080201 , "ISA system timer" },
+ { 0x080202 , "EISA system timer-pair" },
+
+ { 0x080300 , "Generic RTC controller" },
+ { 0x080301 , "ISA RTC controller" },
+
+ { 0x080400 , "Generic PCI Hot-Plug controller" },
+ { 0x080500 , "SD Host controller" },
+ { 0x088000 , "System peripheral" },
+
+ { 0x090000 , "Keyboard controller" },
+ { 0x090100 , "Digitizer (pen)" },
+ { 0x090200 , "Mouse controller" },
+ { 0x090300 , "Scanner controller" },
+ { 0x090400 , "Generic Gameport controller" },
+ { 0x090410 , "Legacy Gameport controller" },
+ { 0x098000 , "Input controller" },
+
+ { 0x0a0000 , "Generic docking station" },
+ { 0x0a8000 , "Docking station" },
+
+ { 0x0b0000 , "386 Processor" },
+ { 0x0b0100 , "486 Processor" },
+ { 0x0b0200 , "Pentium Processor" },
+ { 0x0b1000 , "Alpha Processor" },
+ { 0x0b2000 , "PowerPC Processor" },
+ { 0x0b3000 , "MIPS Processor" },
+ { 0x0b4000 , "Co-processor" },
+
+ { 0x0c0000 , "IEEE 1394 (FireWire)" },
+ { 0x0c0010 , "IEEE 1394 -- OpenHCI spec" },
+ { 0x0c0100 , "ACCESS.bus" },
+ { 0x0c0200 , "SSA" },
+ { 0x0c0300 , "Universal Serial Bus (UHC spec)" },
+ { 0x0c0310 , "Universal Serial Bus (Open Host spec)" },
+ { 0x0c0320 , "USB2 Host controller (Intel Enhanced HCI spec)" },
+ { 0x0c0380 , "Universal Serial Bus (no PI spec)" },
+ { 0x0c03FE , "USB Target Device" },
+ { 0x0c0400 , "Fibre Channel" },
+ { 0x0c0500 , "System Management Bus" },
+ { 0x0c0600 , "InfiniBand" },
+ { 0x0c0700 , "IPMI SMIC Interface" },
+ { 0x0c0701 , "IPMI Kybd Controller Style Interface" },
+ { 0x0c0702 , "IPMI Block Transfer Interface" },
+ /* { 0x0c08xx , "SERCOS Interface" }, */
+ { 0x0c0900 , "CANbus" },
+
+ { 0x0d100 , "iRDA compatible controller" },
+ { 0x0d100 , "Consumer IR controller" },
+ { 0x0d100 , "RF controller" },
+ { 0x0d100 , "Bluetooth controller" },
+ { 0x0d100 , "Broadband controller" },
+ { 0x0d100 , "Ethernet (802.11a 5 GHz) controller" },
+ { 0x0d100 , "Ethernet (802.11b 2.4 GHz) controller" },
+ { 0x0d100 , "Wireless controller" },
+
+ /* { 0x0e00xx , "I2O Intelligent I/O, spec 1.0" }, */
+ { 0x0e0000 , "Message FIFO at offset 040h" },
+
+ { 0x0f0100 , "TV satellite comm. controller" },
+ { 0x0f0200 , "Audio satellite comm. controller" },
+ { 0x0f0300 , "Voice satellite comm. controller" },
+ { 0x0f0400 , "Data satellite comm. controller" },
+
+ { 0x100000 , "Network and computing en/decryption" },
+ { 0x101000 , "Entertainment en/decryption" },
+ { 0x108000 , "En/Decryption" },
+
+ { 0x110000 , "DPIO modules" },
+ { 0x110100 , "Perf. counters" },
+ { 0x111000 , "Comm. synch., time and freq. test" },
+ { 0x112000 , "Management card" },
+ { 0x118000 , "Data acq./Signal proc." },
+
+};
+
+
+/* **************************************************************************
+ *
+ * PCI Class Code name calculations are further complicated by the
+ * fact that there are some combinations of Base Class and
+ * Sub-Class for which no specific register-level programming
+ * interfaces are defined, or, in other words, for which all
+ * possible numeric values of Programming Interface codes
+ * (i.e., the low-byte) are valid.
+ *
+ * The following table lists the Base Class / Sub-Class pairs to
+ * accept without matching the Programming Interface, along
+ * with their names.
+ *
+ **************************************************************************** */
+
+
+static const num_to_name_table pci_all_prg_intfcs_table[] = {
+ { 0x0101 , "IDE controller" },
+ { 0x0206 , "PICMG 2.14 Multi Computing" },
+ { 0x0608 , "RACEway bridge" },
+ { 0x0c08 , "SERCOS Interface" },
+ { 0x0e00 , "I2O Intelligent I/O, spec 1.0" },
+};
+
+
+/* **************************************************************************
+ *
+ * Function name: pci_device_class_name
+ * Synopsis: Return the Device Class Name for the given Class Code
+ *
+ * Inputs:
+ * Parameters:
+ * u32 code Numeric PCI Class Code
+ *
+ * Outputs:
+ * Returned Value: Pointer to string giving the Device Class Name
+ *
+ * Error Detection:
+ * Unrecognized Class Code
+ * String returned is "unknown"
+ *
+ * Process Explanation:
+ * Scan the pci_dev_class_name_table for a match.
+ * If one is not found there, drop the low (Programming Interface)
+ * byte of the code and scan the pci_all_prg_intfcs_table
+ * for a match that way
+ * If you didn't find one there, you've exhausted your options...
+ *
+ **************************************************************************** */
+
+const char *pci_device_class_name( u32 code)
+{
+ const int pdc_max_indx =
+ sizeof(pci_dev_class_name_table)/sizeof(num_to_name_table) ;
+ const char *result ;
+
+ result = convert_num_to_name(
+ code,
+ (num_to_name_table *)pci_dev_class_name_table,
+ pdc_max_indx,
+ NULL);
+
+ if ( result == NULL)
+ {
+ const int pallpi_max_indx =
+ sizeof(pci_all_prg_intfcs_table)/sizeof(num_to_name_table) ;
+
+ result = convert_num_to_name(
+ code>>8,
+ (num_to_name_table *)pci_all_prg_intfcs_table,
+ pallpi_max_indx,
+ "unknown");
+ }
+ return ( result );
+}
+
+
+/* **************************************************************************
+ *
+ * Function name: pci_code_type_name
+ * Synopsis: Return a printable Name for the given PCI Code Type
+ *
+ * Inputs:
+ * Parameters:
+ * u8 code Numeric PCI Code Type
+ *
+ * Outputs:
+ * Returned Value: Pointer to string giving printable Name
+ *
+ * Error Detection:
+ * Unrecognized PCI Code Type
+ * String returned is "unknown as of PCI specs 2.2"
+ *
+ * Process Explanation:
+ * Scan the pci_code_type_name_table for a match.
+ *
+ *
+ **************************************************************************** */
+
+const char *pci_code_type_name(u8 code)
+{
+ const int pct_max_indx =
+ sizeof(pci_code_type_name_table)/sizeof(num_to_name_table) ;
+ const char *result ;
+
+ result = convert_num_to_name(
+ (u32)code,
+ (num_to_name_table *)pci_code_type_name_table,
+ pct_max_indx,
+ "unknown as of PCI specs 2.2");
+ return ( result );
+}
+
diff --git a/shared/pcihdr.h b/shared/pcihdr.h
new file mode 100644
index 0000000..909f06c
--- /dev/null
+++ b/shared/pcihdr.h
@@ -0,0 +1,176 @@
+#ifndef _PCIHDR_H
+#define _PCIHDR_H
+/*
+ * OpenBIOS - free your system!
+ * ( PCI headers )
+ *
+ * This program is part of a free implementation of the IEEE 1275-1994
+ * Standard for Boot (Initialization Configuration) Firmware.
+ *
+ * Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
+ * Copyright (C) 2006 coresystems GmbH <info@coresystems.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ *
+ */
+
+/* **************************************************************************
+ *
+ * PCI Header and PCI Data Structures, as defined in
+ * PCI FIRMWARE SPECIFICATION, REV. 3.
+ * taken from openbios/utils/romheaders/romheaders.c
+ *
+ * (C) Copyright 2005 IBM Corporation. All Rights Reserved.
+ * Module Author: David L. Paktor dlpaktor@us.ibm.com
+ *
+ *
+ **************************************************************************** */
+
+
+/* **************************************************************************
+ *
+ * Structures:
+ * rom_header_t Type definition for a PCI ROM Header
+ * pci_data_t Type definition for a PCI Data Header
+ *
+ *
+ * Macros:
+ * PCI_DATA_HDR Construct the PCI Data Header signature
+ * as an integer. Use this to create
+ * a constant, in order to allow its
+ * value to be calculated at compile-
+ * -time rather than at run-time.
+ * BIG_ENDIAN_WORD_FETCH Fetch a big-endian word from 2
+ * unsigned chars in sequence.
+ * LITTLE_ENDIAN_WORD_FETCH ...... little-endian word from 2 ....
+ * BIG_ENDIAN_LONG_FETCH ...... big-endian long from 4 ...
+ * LITTLE_ENDIAN_LONG_FETCH ...... little-endian long from 4 ....
+ * LITTLE_ENDIAN_TRIPLET_FETCH ...... little-endian triplet from 3 ...
+ * CLASS_CODE_FETCH Special fetch for Class-Code triplet
+ * BIG_ENDIAN_WORD_STORE Store an integer into 2 unsigned
+ * chars in big-endian sequence
+ * LITTLE_ENDIAN_WORD_STORE ..... into 2 ... little-endian ...
+ * BIG_ENDIAN_LONG_STORE ..... into 4 ... big-endian ...
+ * LITTLE_ENDIAN_LONG_STORE ..... into 4 ... little-endian ...
+ * LITTLE_ENDIAN_TRIPLET_STORE ..... 3 ... little-endian triplet ...
+ * CLASS_CODE_STORE Special store for Class-Code triplet
+ *
+ **************************************************************************** */
+
+/* **************************************************************************
+ *
+ * Still to be done:
+ * The "Endian" macros are beginning to appear to be more
+ * generally useful that previously thought, and should,
+ * perhaps, be moved into types.h
+ *
+ **************************************************************************** */
+
+#include "types.h"
+/* Construct the PCI Data Header signature as an integer */
+#define PCI_DATA_HDR (u32) ( ('P' << 24) | ('C' << 16) | ('I' << 8) | 'R' )
+
+#ifndef bswap_16
+#define bswap_16(x) \
+ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
+#endif
+
+#define little_word(x) bswap_16(x)
+
+/* These are mnemonics for the programmer. The compiler doesn't care... */
+#define le_u16(x) u8 x[2]
+#define be_u16(x) u8 x[2]
+#define le_u32(x) u8 x[4]
+#define be_u32(x) u8 x[4]
+
+/* Fetch a big-endian word from 2 unsigned chars in sequence */
+#define BIG_ENDIAN_WORD_FETCH(x) (u16)( (x[0] << 8) | x[1] )
+
+/* Fetch a little-endian word from 2 unsigned chars in sequence */
+#define LITTLE_ENDIAN_WORD_FETCH(x) (u16)( (x[1] << 8) | x[0] )
+
+/* Fetch a big-endian long from 4 unsigned chars in sequence */
+#define BIG_ENDIAN_LONG_FETCH(x) (u32)( (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3] )
+
+/* Fetch a little-endian long from 4 unsigned chars in sequence */
+#define LITTLE_ENDIAN_LONG_FETCH(x) (u32)( (x[3] << 24) | (x[2] << 16) | (x[1] << 8) | x[0] )
+
+#define LE_U24(x) u8 x[3]
+/* Fetch a little-endian triplet from 3 unsigned chars in sequence */
+#define LITTLE_ENDIAN_TRIPLET_FETCH(x) (u32)( (x[2] << 16) | (x[1] << 8) | x[0] )
+
+
+/* Special case for Class-Code triplet: lo, mid, hi */
+#define class_code_u24(x) u8 x[3]
+/* Special fetch for Class-Code triplet */
+#define CLASS_CODE_FETCH(x) (u32)( (x[2] << 16) | (x[1] << 8) | x[0] )
+/* Special store for Class-Code triplet */
+#define CLASS_CODE_STORE(dest,x) \
+ dest[2] = (u8)( x >> 16); dest[1] = (u8)(x >> 8); dest[0] = (u8)x;
+ /* NOTE Class-Code triplet is the same as little-endian triplet */
+ /* Change over some time, eh? */
+
+/* Store an integer into 2 unsigned chars in big-endian sequence */
+#define BIG_ENDIAN_WORD_STORE(dest,x) dest[0] = (u8)(x >> 8); dest[1]=(u8)x;
+
+/* Store an integer into 2 unsigned chars in little-endian sequence */
+#define LITTLE_ENDIAN_WORD_STORE(dest,x) dest[1] = (u8)(x >> 8); dest[0]=(u8)x;
+
+/* Store an integer into 4 unsigned chars in big-endian sequence */
+#define BIG_ENDIAN_LONG_STORE(dest,x) \
+ dest[0] = (u8)(x >> 24); dest[1] =(u8)( x >> 16); \
+ dest[2] = (u8)(x >> 8); dest[3] =(u8)x;
+
+/* Store an integer into 4 unsigned chars in little-endian sequence */
+#define LITTLE_ENDIAN_LONG_STORE(dest,x) \
+ dest[3] = (u8)(x >> 24); dest[2] =(u8)( x >> 16); \
+ dest[1] = (u8)(x >> 8); dest[0] =(u8)x;
+
+/* Store an integer into 3 unsigned chars in little-endian triplet sequence */
+#define LITTLE_ENDIAN_TRIPLET_STORE(dest,x) \
+ dest[2] = (u8)( x >> 16); dest[1] = (u8)(x >> 8); dest[0] = (u8)x;
+
+
+typedef struct {
+ be_u16(signature);
+ u8 reserved[0x16];
+ le_u16(data_ptr);
+ le_u16(padd);
+} rom_header_t;
+
+
+typedef struct {
+ be_u32 (signature);
+ le_u16 (vendor);
+ le_u16 (device);
+ le_u16 (vpd);
+ le_u16 (dlen);
+ u8 drevision;
+ class_code_u24 (class_code);
+ le_u16 (ilen);
+ le_u16 (irevision);
+ u8 code_type;
+ u8 last_image_flag;
+ u16 reserved_2;
+} pci_data_t;
+
+#define PCI_DATA_STRUCT_REV 0
+
+/* Prototypes for functions exported from devsupp/pci/classcodes.c */
+char *pci_device_class_name( u32 code);
+char *pci_code_type_name(u8 code);
+
+
+
+#endif /* _PCIHDR_H */
diff --git a/shared/types.h b/shared/types.h
new file mode 100644
index 0000000..300b96a
--- /dev/null
+++ b/shared/types.h
@@ -0,0 +1,97 @@
+#ifndef _OPENBIOS_TYPES_H
+#define _OPENBIOS_TYPES_H
+
+/*
+ * OpenBIOS - free your system!
+ * ( FCode tokenizer )
+ *
+ * This program is part of a free implementation of the IEEE 1275-1994
+ * Standard for Boot (Initialization Configuration) Firmware.
+ *
+ * Copyright (C) 2001-2005 Stefan Reinauer, <stepan@openbios.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ *
+ */
+
+/* **************************************************************************
+ *
+ * Convert system short-name data-types found in asm/types.h
+ * to OpenBios-style names. (Mainly, remove the leading
+ * double-Underbar).
+ *
+ * Also, define a very useful "bool" type for logical operations,
+ * and maybe a macro (or several) to go with it...
+ *
+ * (C) Copyright 2005 IBM Corporation. All Rights Reserved.
+ * Module Author: David L. Paktor dlpaktor@us.ibm.com
+ *
+ **************************************************************************** */
+
+
+#include <asm/types.h>
+
+typedef __s8 s8;
+typedef __u8 u8;
+
+typedef __s16 s16;
+typedef __u16 u16;
+
+typedef __s32 s32;
+typedef __u32 u32;
+
+#ifdef FALSE /* Hack for AIX. */
+#undef FALSE
+#undef TRUE
+#endif /* Hack for AIX. */
+
+typedef enum boolean { FALSE = 0 , TRUE = -1 } bool ;
+
+
+/* **************************************************************************
+ * Macro Name: BOOLVAL
+ * Convert the supplied variable or expression to
+ * a formal boolean.
+ * Argument:
+ * x (bool) Variable or expression, operand.
+ *
+ **************************************************************************** */
+
+#define BOOLVAL(x) (x ? TRUE : FALSE)
+
+
+/* **************************************************************************
+ * Macro Name: INVERSE
+ * Return the logical inversion of the
+ * supplied boolean variable or expression.
+ * Argument:
+ * x (bool) Variable or expression, operand.
+ *
+ **************************************************************************** */
+
+#define INVERSE(x) (x ? FALSE : TRUE)
+
+
+/* **************************************************************************
+*
+ * Some hacks stuck in for systems w/ incomplete includes
+ * or libraries or whatever.
+ *
+ **************************************************************************** */
+
+#ifndef _PTR
+#define _PTR void *
+#endif
+
+#endif /* _OPENBIOS_TYPES_H */