v86 0.4.0 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +56 -111
- package/build/libv86-debug.js +12680 -0
- package/build/libv86-debug.mjs +732 -0
- package/build/libv86.js +710 -0
- package/build/libv86.mjs +637 -0
- package/build/v86-debug.wasm +0 -0
- package/build/v86-fallback.wasm +0 -0
- package/build/v86.wasm +0 -0
- package/package.json +12 -35
- package/bios/.gitignore +0 -1
- package/bios/COPYING.LESSER +0 -165
- package/bios/bochs-bios.bin +0 -0
- package/bios/bochs-vgabios.bin +0 -0
- package/bios/fetch-and-build-seabios.sh +0 -13
- package/bios/seabios/.config +0 -113
- package/bios/seabios/.config.old +0 -114
- package/bios/seabios/.gitignore +0 -4
- package/bios/seabios/COPYING +0 -674
- package/bios/seabios/COPYING.LESSER +0 -165
- package/bios/seabios/Makefile +0 -286
- package/bios/seabios/README +0 -17
- package/bios/seabios/docs/Build_overview.md +0 -104
- package/bios/seabios/docs/Contributing.md +0 -20
- package/bios/seabios/docs/Debugging.md +0 -111
- package/bios/seabios/docs/Developer_Documentation.md +0 -25
- package/bios/seabios/docs/Developer_links.md +0 -86
- package/bios/seabios/docs/Download.md +0 -27
- package/bios/seabios/docs/Execution_and_code_flow.md +0 -178
- package/bios/seabios/docs/Linking_overview.md +0 -160
- package/bios/seabios/docs/Mailinglist.md +0 -8
- package/bios/seabios/docs/Memory_Model.md +0 -253
- package/bios/seabios/docs/README +0 -5
- package/bios/seabios/docs/Releases.md +0 -482
- package/bios/seabios/docs/Runtime_config.md +0 -193
- package/bios/seabios/docs/SeaBIOS.md +0 -17
- package/bios/seabios/docs/SeaVGABIOS.md +0 -39
- package/bios/seabios/out/autoconf.h +0 -117
- package/bios/seabios/out/include/config/acpi/dsdt.h +0 -0
- package/bios/seabios/out/include/config/acpi.h +0 -0
- package/bios/seabios/out/include/config/ahci.h +0 -0
- package/bios/seabios/out/include/config/apmbios.h +0 -0
- package/bios/seabios/out/include/config/ata/dma.h +0 -0
- package/bios/seabios/out/include/config/ata/pio32.h +0 -0
- package/bios/seabios/out/include/config/ata.h +0 -0
- package/bios/seabios/out/include/config/auto.conf +0 -69
- package/bios/seabios/out/include/config/auto.conf.cmd +0 -9
- package/bios/seabios/out/include/config/boot.h +0 -0
- package/bios/seabios/out/include/config/bootorder.h +0 -0
- package/bios/seabios/out/include/config/build/vgabios.h +0 -0
- package/bios/seabios/out/include/config/call32/smm.h +0 -0
- package/bios/seabios/out/include/config/cdrom/boot.h +0 -0
- package/bios/seabios/out/include/config/cdrom/emu.h +0 -0
- package/bios/seabios/out/include/config/debug/level.h +0 -0
- package/bios/seabios/out/include/config/drives.h +0 -0
- package/bios/seabios/out/include/config/entry/extrastack.h +0 -0
- package/bios/seabios/out/include/config/esp/scsi.h +0 -0
- package/bios/seabios/out/include/config/flash/floppy.h +0 -0
- package/bios/seabios/out/include/config/floppy.h +0 -0
- package/bios/seabios/out/include/config/fw/romfile/load.h +0 -0
- package/bios/seabios/out/include/config/hardware/irq.h +0 -0
- package/bios/seabios/out/include/config/kbd/call/int15/4f.h +0 -0
- package/bios/seabios/out/include/config/keyboard.h +0 -0
- package/bios/seabios/out/include/config/lpt.h +0 -0
- package/bios/seabios/out/include/config/lsi/scsi.h +0 -0
- package/bios/seabios/out/include/config/malloc/uppermemory.h +0 -0
- package/bios/seabios/out/include/config/megasas.h +0 -0
- package/bios/seabios/out/include/config/mouse.h +0 -0
- package/bios/seabios/out/include/config/mpt/scsi.h +0 -0
- package/bios/seabios/out/include/config/mptable.h +0 -0
- package/bios/seabios/out/include/config/mtrr/init.h +0 -0
- package/bios/seabios/out/include/config/optionroms.h +0 -0
- package/bios/seabios/out/include/config/override/pci/id.h +0 -0
- package/bios/seabios/out/include/config/pcibios.h +0 -0
- package/bios/seabios/out/include/config/pirtable.h +0 -0
- package/bios/seabios/out/include/config/pmm.h +0 -0
- package/bios/seabios/out/include/config/pmtimer.h +0 -0
- package/bios/seabios/out/include/config/pnpbios.h +0 -0
- package/bios/seabios/out/include/config/ps2port.h +0 -0
- package/bios/seabios/out/include/config/pvscsi.h +0 -0
- package/bios/seabios/out/include/config/qemu/hardware.h +0 -0
- package/bios/seabios/out/include/config/qemu.h +0 -0
- package/bios/seabios/out/include/config/rom/size.h +0 -0
- package/bios/seabios/out/include/config/rtc/timer.h +0 -0
- package/bios/seabios/out/include/config/s3/resume.h +0 -0
- package/bios/seabios/out/include/config/sdcard.h +0 -0
- package/bios/seabios/out/include/config/serial.h +0 -0
- package/bios/seabios/out/include/config/tcgbios.h +0 -0
- package/bios/seabios/out/include/config/threads.h +0 -0
- package/bios/seabios/out/include/config/tristate.conf +0 -4
- package/bios/seabios/out/include/config/tsc/timer.h +0 -0
- package/bios/seabios/out/include/config/use/smm.h +0 -0
- package/bios/seabios/out/include/config/vga/allocate/extra/stack.h +0 -0
- package/bios/seabios/out/include/config/vga/bochs/stdvga.h +0 -0
- package/bios/seabios/out/include/config/vga/bochs.h +0 -0
- package/bios/seabios/out/include/config/vga/did.h +0 -0
- package/bios/seabios/out/include/config/vga/extra/stack/size.h +0 -0
- package/bios/seabios/out/include/config/vga/fixup/asm.h +0 -0
- package/bios/seabios/out/include/config/vga/pci.h +0 -0
- package/bios/seabios/out/include/config/vga/stdvga/ports.h +0 -0
- package/bios/seabios/out/include/config/vga/vbe.h +0 -0
- package/bios/seabios/out/include/config/vga/vid.h +0 -0
- package/bios/seabios/out/include/config/vgahooks.h +0 -0
- package/bios/seabios/out/include/config/virtio/blk.h +0 -0
- package/bios/seabios/out/include/config/virtio/scsi.h +0 -0
- package/bios/seabios/out/include/config/xen.h +0 -0
- package/bios/seabios/out/scripts/kconfig/conf +0 -0
- package/bios/seabios/out/scripts/kconfig/conf.o +0 -0
- package/bios/seabios/out/scripts/kconfig/zconf.hash.c +0 -289
- package/bios/seabios/out/scripts/kconfig/zconf.lex.c +0 -2420
- package/bios/seabios/out/scripts/kconfig/zconf.tab.c +0 -2538
- package/bios/seabios/out/scripts/kconfig/zconf.tab.o +0 -0
- package/bios/seabios/scripts/acpi_extract.py +0 -366
- package/bios/seabios/scripts/acpi_extract_preprocess.py +0 -41
- package/bios/seabios/scripts/buildrom.py +0 -56
- package/bios/seabios/scripts/buildversion.py +0 -134
- package/bios/seabios/scripts/checkrom.py +0 -95
- package/bios/seabios/scripts/checkstack.py +0 -226
- package/bios/seabios/scripts/checksum.py +0 -16
- package/bios/seabios/scripts/encodeint.py +0 -21
- package/bios/seabios/scripts/gen-offsets.sh +0 -17
- package/bios/seabios/scripts/kconfig/.gitignore +0 -22
- package/bios/seabios/scripts/kconfig/Makefile +0 -331
- package/bios/seabios/scripts/kconfig/POTFILES.in +0 -12
- package/bios/seabios/scripts/kconfig/check.sh +0 -13
- package/bios/seabios/scripts/kconfig/conf.c +0 -718
- package/bios/seabios/scripts/kconfig/confdata.c +0 -1250
- package/bios/seabios/scripts/kconfig/expr.c +0 -1168
- package/bios/seabios/scripts/kconfig/expr.h +0 -241
- package/bios/seabios/scripts/kconfig/gconf.c +0 -1542
- package/bios/seabios/scripts/kconfig/gconf.glade +0 -661
- package/bios/seabios/scripts/kconfig/images.c +0 -326
- package/bios/seabios/scripts/kconfig/kxgettext.c +0 -235
- package/bios/seabios/scripts/kconfig/lex.zconf.c +0 -2430
- package/bios/seabios/scripts/kconfig/list.h +0 -131
- package/bios/seabios/scripts/kconfig/lkc.h +0 -200
- package/bios/seabios/scripts/kconfig/lkc_proto.h +0 -57
- package/bios/seabios/scripts/kconfig/lxdialog/.gitignore +0 -4
- package/bios/seabios/scripts/kconfig/lxdialog/BIG.FAT.WARNING +0 -4
- package/bios/seabios/scripts/kconfig/lxdialog/check-lxdialog.sh +0 -87
- package/bios/seabios/scripts/kconfig/lxdialog/checklist.c +0 -332
- package/bios/seabios/scripts/kconfig/lxdialog/dialog.h +0 -257
- package/bios/seabios/scripts/kconfig/lxdialog/inputbox.c +0 -301
- package/bios/seabios/scripts/kconfig/lxdialog/menubox.c +0 -437
- package/bios/seabios/scripts/kconfig/lxdialog/textbox.c +0 -408
- package/bios/seabios/scripts/kconfig/lxdialog/util.c +0 -713
- package/bios/seabios/scripts/kconfig/lxdialog/yesno.c +0 -114
- package/bios/seabios/scripts/kconfig/mconf.c +0 -1036
- package/bios/seabios/scripts/kconfig/menu.c +0 -697
- package/bios/seabios/scripts/kconfig/merge_config.sh +0 -150
- package/bios/seabios/scripts/kconfig/nconf.c +0 -1556
- package/bios/seabios/scripts/kconfig/nconf.gui.c +0 -656
- package/bios/seabios/scripts/kconfig/nconf.h +0 -96
- package/bios/seabios/scripts/kconfig/qconf.cc +0 -1795
- package/bios/seabios/scripts/kconfig/qconf.h +0 -338
- package/bios/seabios/scripts/kconfig/streamline_config.pl +0 -647
- package/bios/seabios/scripts/kconfig/symbol.c +0 -1373
- package/bios/seabios/scripts/kconfig/util.c +0 -157
- package/bios/seabios/scripts/kconfig/zconf.gperf +0 -48
- package/bios/seabios/scripts/kconfig/zconf.hash.c_shipped +0 -289
- package/bios/seabios/scripts/kconfig/zconf.l +0 -363
- package/bios/seabios/scripts/kconfig/zconf.lex.c_shipped +0 -2420
- package/bios/seabios/scripts/kconfig/zconf.tab.c_shipped +0 -2538
- package/bios/seabios/scripts/kconfig/zconf.y +0 -733
- package/bios/seabios/scripts/layoutrom.py +0 -705
- package/bios/seabios/scripts/python23compat.py +0 -14
- package/bios/seabios/scripts/readserial.py +0 -190
- package/bios/seabios/scripts/tarball.sh +0 -36
- package/bios/seabios/scripts/test-build.sh +0 -90
- package/bios/seabios/scripts/transdump.py +0 -53
- package/bios/seabios/scripts/vgafixup.py +0 -96
- package/bios/seabios/src/Kconfig +0 -579
- package/bios/seabios/src/apm.c +0 -215
- package/bios/seabios/src/asm-offsets.c +0 -23
- package/bios/seabios/src/biosvar.h +0 -130
- package/bios/seabios/src/block.c +0 -623
- package/bios/seabios/src/block.h +0 -121
- package/bios/seabios/src/bmp.c +0 -117
- package/bios/seabios/src/boot.c +0 -793
- package/bios/seabios/src/bootsplash.c +0 -255
- package/bios/seabios/src/bregs.h +0 -80
- package/bios/seabios/src/byteorder.h +0 -71
- package/bios/seabios/src/cdrom.c +0 -322
- package/bios/seabios/src/clock.c +0 -506
- package/bios/seabios/src/code16gcc.s +0 -1
- package/bios/seabios/src/config.h +0 -108
- package/bios/seabios/src/cp437.c +0 -275
- package/bios/seabios/src/cp437.h +0 -1
- package/bios/seabios/src/disk.c +0 -779
- package/bios/seabios/src/e820map.c +0 -152
- package/bios/seabios/src/e820map.h +0 -26
- package/bios/seabios/src/entryfuncs.S +0 -165
- package/bios/seabios/src/farptr.h +0 -208
- package/bios/seabios/src/font.c +0 -139
- package/bios/seabios/src/fw/acpi-dsdt-cpu-hotplug.dsl +0 -78
- package/bios/seabios/src/fw/acpi-dsdt-dbug.dsl +0 -26
- package/bios/seabios/src/fw/acpi-dsdt-hpet.dsl +0 -36
- package/bios/seabios/src/fw/acpi-dsdt-isa.dsl +0 -102
- package/bios/seabios/src/fw/acpi-dsdt-pci-crs.dsl +0 -90
- package/bios/seabios/src/fw/acpi-dsdt.dsl +0 -342
- package/bios/seabios/src/fw/acpi-dsdt.hex +0 -554
- package/bios/seabios/src/fw/acpi.c +0 -685
- package/bios/seabios/src/fw/biostables.c +0 -491
- package/bios/seabios/src/fw/coreboot.c +0 -569
- package/bios/seabios/src/fw/csm.c +0 -347
- package/bios/seabios/src/fw/dev-pci.h +0 -52
- package/bios/seabios/src/fw/dev-piix.h +0 -29
- package/bios/seabios/src/fw/dev-q35.h +0 -52
- package/bios/seabios/src/fw/lzmadecode.c +0 -398
- package/bios/seabios/src/fw/lzmadecode.h +0 -67
- package/bios/seabios/src/fw/mptable.c +0 -197
- package/bios/seabios/src/fw/mtrr.c +0 -105
- package/bios/seabios/src/fw/multiboot.c +0 -111
- package/bios/seabios/src/fw/paravirt.c +0 -624
- package/bios/seabios/src/fw/paravirt.h +0 -63
- package/bios/seabios/src/fw/pciinit.c +0 -1187
- package/bios/seabios/src/fw/pirtable.c +0 -103
- package/bios/seabios/src/fw/q35-acpi-dsdt.dsl +0 -450
- package/bios/seabios/src/fw/romfile_loader.c +0 -259
- package/bios/seabios/src/fw/romfile_loader.h +0 -91
- package/bios/seabios/src/fw/shadow.c +0 -208
- package/bios/seabios/src/fw/smbios.c +0 -585
- package/bios/seabios/src/fw/smm.c +0 -269
- package/bios/seabios/src/fw/smp.c +0 -194
- package/bios/seabios/src/fw/ssdt-misc.dsl +0 -104
- package/bios/seabios/src/fw/ssdt-misc.hex +0 -88
- package/bios/seabios/src/fw/ssdt-pcihp.dsl +0 -36
- package/bios/seabios/src/fw/ssdt-pcihp.hex +0 -38
- package/bios/seabios/src/fw/ssdt-proc.dsl +0 -48
- package/bios/seabios/src/fw/ssdt-proc.hex +0 -35
- package/bios/seabios/src/fw/xen.c +0 -149
- package/bios/seabios/src/fw/xen.h +0 -125
- package/bios/seabios/src/gen-defs.h +0 -19
- package/bios/seabios/src/hw/ahci.c +0 -697
- package/bios/seabios/src/hw/ahci.h +0 -201
- package/bios/seabios/src/hw/ata.c +0 -1046
- package/bios/seabios/src/hw/ata.h +0 -163
- package/bios/seabios/src/hw/blockcmd.c +0 -372
- package/bios/seabios/src/hw/blockcmd.h +0 -114
- package/bios/seabios/src/hw/dma.c +0 -67
- package/bios/seabios/src/hw/esp-scsi.c +0 -241
- package/bios/seabios/src/hw/esp-scsi.h +0 -8
- package/bios/seabios/src/hw/floppy.c +0 -741
- package/bios/seabios/src/hw/lsi-scsi.c +0 -221
- package/bios/seabios/src/hw/lsi-scsi.h +0 -8
- package/bios/seabios/src/hw/megasas.c +0 -405
- package/bios/seabios/src/hw/megasas.h +0 -8
- package/bios/seabios/src/hw/mpt-scsi.c +0 -319
- package/bios/seabios/src/hw/mpt-scsi.h +0 -8
- package/bios/seabios/src/hw/nvme-int.h +0 -199
- package/bios/seabios/src/hw/nvme.c +0 -708
- package/bios/seabios/src/hw/nvme.h +0 -17
- package/bios/seabios/src/hw/pci.c +0 -133
- package/bios/seabios/src/hw/pci.h +0 -47
- package/bios/seabios/src/hw/pci_ids.h +0 -2632
- package/bios/seabios/src/hw/pci_regs.h +0 -556
- package/bios/seabios/src/hw/pcidevice.c +0 -192
- package/bios/seabios/src/hw/pcidevice.h +0 -76
- package/bios/seabios/src/hw/pic.c +0 -115
- package/bios/seabios/src/hw/pic.h +0 -60
- package/bios/seabios/src/hw/ps2port.c +0 -543
- package/bios/seabios/src/hw/ps2port.h +0 -67
- package/bios/seabios/src/hw/pvscsi.c +0 -333
- package/bios/seabios/src/hw/pvscsi.h +0 -8
- package/bios/seabios/src/hw/ramdisk.c +0 -108
- package/bios/seabios/src/hw/rtc.c +0 -100
- package/bios/seabios/src/hw/rtc.h +0 -75
- package/bios/seabios/src/hw/sdcard.c +0 -572
- package/bios/seabios/src/hw/serialio.c +0 -113
- package/bios/seabios/src/hw/serialio.h +0 -29
- package/bios/seabios/src/hw/timer.c +0 -259
- package/bios/seabios/src/hw/tpm_drivers.c +0 -636
- package/bios/seabios/src/hw/tpm_drivers.h +0 -127
- package/bios/seabios/src/hw/usb-ehci.c +0 -650
- package/bios/seabios/src/hw/usb-ehci.h +0 -177
- package/bios/seabios/src/hw/usb-hid.c +0 -442
- package/bios/seabios/src/hw/usb-hid.h +0 -29
- package/bios/seabios/src/hw/usb-hub.c +0 -205
- package/bios/seabios/src/hw/usb-hub.h +0 -64
- package/bios/seabios/src/hw/usb-msc.c +0 -222
- package/bios/seabios/src/hw/usb-msc.h +0 -10
- package/bios/seabios/src/hw/usb-ohci.c +0 -568
- package/bios/seabios/src/hw/usb-ohci.h +0 -144
- package/bios/seabios/src/hw/usb-uas.c +0 -289
- package/bios/seabios/src/hw/usb-uas.h +0 -9
- package/bios/seabios/src/hw/usb-uhci.c +0 -571
- package/bios/seabios/src/hw/usb-uhci.h +0 -128
- package/bios/seabios/src/hw/usb-xhci.c +0 -1161
- package/bios/seabios/src/hw/usb-xhci.h +0 -133
- package/bios/seabios/src/hw/usb.c +0 -499
- package/bios/seabios/src/hw/usb.h +0 -254
- package/bios/seabios/src/hw/virtio-blk.c +0 -211
- package/bios/seabios/src/hw/virtio-blk.h +0 -43
- package/bios/seabios/src/hw/virtio-pci.c +0 -501
- package/bios/seabios/src/hw/virtio-pci.h +0 -151
- package/bios/seabios/src/hw/virtio-ring.c +0 -147
- package/bios/seabios/src/hw/virtio-ring.h +0 -121
- package/bios/seabios/src/hw/virtio-scsi.c +0 -220
- package/bios/seabios/src/hw/virtio-scsi.h +0 -47
- package/bios/seabios/src/jpeg.c +0 -1055
- package/bios/seabios/src/kbd.c +0 -599
- package/bios/seabios/src/list.h +0 -91
- package/bios/seabios/src/malloc.c +0 -561
- package/bios/seabios/src/malloc.h +0 -70
- package/bios/seabios/src/memmap.h +0 -21
- package/bios/seabios/src/misc.c +0 -195
- package/bios/seabios/src/mouse.c +0 -342
- package/bios/seabios/src/optionroms.c +0 -475
- package/bios/seabios/src/output.c +0 -584
- package/bios/seabios/src/output.h +0 -68
- package/bios/seabios/src/pcibios.c +0 -241
- package/bios/seabios/src/pmm.c +0 -176
- package/bios/seabios/src/pnpbios.c +0 -88
- package/bios/seabios/src/post.c +0 -337
- package/bios/seabios/src/resume.c +0 -157
- package/bios/seabios/src/romfile.c +0 -146
- package/bios/seabios/src/romfile.h +0 -21
- package/bios/seabios/src/romlayout.S +0 -698
- package/bios/seabios/src/sercon.c +0 -677
- package/bios/seabios/src/serial.c +0 -317
- package/bios/seabios/src/sha1.c +0 -147
- package/bios/seabios/src/sha1.h +0 -8
- package/bios/seabios/src/stacks.c +0 -771
- package/bios/seabios/src/stacks.h +0 -68
- package/bios/seabios/src/std/LegacyBios.h +0 -985
- package/bios/seabios/src/std/acpi.h +0 -323
- package/bios/seabios/src/std/bda.h +0 -174
- package/bios/seabios/src/std/disk.h +0 -175
- package/bios/seabios/src/std/mptable.h +0 -77
- package/bios/seabios/src/std/multiboot.h +0 -260
- package/bios/seabios/src/std/optionrom.h +0 -59
- package/bios/seabios/src/std/pirtable.h +0 -35
- package/bios/seabios/src/std/pmm.h +0 -19
- package/bios/seabios/src/std/pnpbios.h +0 -24
- package/bios/seabios/src/std/smbios.h +0 -167
- package/bios/seabios/src/std/tcg.h +0 -554
- package/bios/seabios/src/std/vbe.h +0 -156
- package/bios/seabios/src/std/vga.h +0 -63
- package/bios/seabios/src/string.c +0 -251
- package/bios/seabios/src/string.h +0 -31
- package/bios/seabios/src/system.c +0 -357
- package/bios/seabios/src/tcgbios.c +0 -2014
- package/bios/seabios/src/tcgbios.h +0 -19
- package/bios/seabios/src/types.h +0 -156
- package/bios/seabios/src/util.h +0 -251
- package/bios/seabios/src/version.c +0 -5
- package/bios/seabios/src/vgahooks.c +0 -355
- package/bios/seabios/src/x86.c +0 -23
- package/bios/seabios/src/x86.h +0 -277
- package/bios/seabios/vgasrc/Kconfig +0 -211
- package/bios/seabios/vgasrc/bochsdisplay.c +0 -59
- package/bios/seabios/vgasrc/bochsvga.c +0 -447
- package/bios/seabios/vgasrc/bochsvga.h +0 -57
- package/bios/seabios/vgasrc/cbvga.c +0 -337
- package/bios/seabios/vgasrc/clext.c +0 -627
- package/bios/seabios/vgasrc/geodevga.c +0 -434
- package/bios/seabios/vgasrc/geodevga.h +0 -89
- package/bios/seabios/vgasrc/ramfb.c +0 -163
- package/bios/seabios/vgasrc/stdvga.c +0 -485
- package/bios/seabios/vgasrc/stdvga.h +0 -81
- package/bios/seabios/vgasrc/stdvgaio.c +0 -186
- package/bios/seabios/vgasrc/stdvgamodes.c +0 -534
- package/bios/seabios/vgasrc/swcursor.c +0 -96
- package/bios/seabios/vgasrc/vbe.c +0 -432
- package/bios/seabios/vgasrc/vgabios.c +0 -1131
- package/bios/seabios/vgasrc/vgabios.h +0 -88
- package/bios/seabios/vgasrc/vgaentry.S +0 -161
- package/bios/seabios/vgasrc/vgafb.c +0 -661
- package/bios/seabios/vgasrc/vgafb.h +0 -42
- package/bios/seabios/vgasrc/vgafonts.c +0 -785
- package/bios/seabios/vgasrc/vgahw.h +0 -152
- package/bios/seabios/vgasrc/vgainit.c +0 -202
- package/bios/seabios/vgasrc/vgalayout.lds.S +0 -23
- package/bios/seabios/vgasrc/vgautil.h +0 -103
- package/bios/seabios/vgasrc/vgaversion.c +0 -6
- package/bios/seabios-debug.bin +0 -0
- package/bios/seabios-debug.config +0 -117
- package/bios/seabios.bin +0 -0
- package/bios/seabios.config +0 -114
- package/bios/vgabios-debug.bin +0 -0
- package/bios/vgabios.bin +0 -0
- package/build/binaries.js +0 -1
- package/build/index-debug.cjs +0 -1
- package/build/index-debug.js +0 -1
- package/build/index.cjs +0 -1
- package/build/index.js +0 -1
- package/v86.css +0 -259
|
@@ -1,1187 +0,0 @@
|
|
|
1
|
-
// Initialize PCI devices (on emulators)
|
|
2
|
-
//
|
|
3
|
-
// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
|
|
4
|
-
// Copyright (C) 2006 Fabrice Bellard
|
|
5
|
-
//
|
|
6
|
-
// This file may be distributed under the terms of the GNU LGPLv3 license.
|
|
7
|
-
|
|
8
|
-
#include "byteorder.h" // le64_to_cpu
|
|
9
|
-
#include "config.h" // CONFIG_*
|
|
10
|
-
#include "dev-q35.h" // Q35_HOST_BRIDGE_PCIEXBAR_ADDR
|
|
11
|
-
#include "dev-piix.h" // PIIX_*
|
|
12
|
-
#include "e820map.h" // e820_add
|
|
13
|
-
#include "hw/ata.h" // PORT_ATA1_CMD_BASE
|
|
14
|
-
#include "hw/pci.h" // pci_config_readl
|
|
15
|
-
#include "hw/pcidevice.h" // pci_probe_devices
|
|
16
|
-
#include "hw/pci_ids.h" // PCI_VENDOR_ID_INTEL
|
|
17
|
-
#include "hw/pci_regs.h" // PCI_COMMAND
|
|
18
|
-
#include "fw/dev-pci.h" // REDHAT_CAP_RESOURCE_RESERVE
|
|
19
|
-
#include "list.h" // struct hlist_node
|
|
20
|
-
#include "malloc.h" // free
|
|
21
|
-
#include "output.h" // dprintf
|
|
22
|
-
#include "paravirt.h" // RamSize
|
|
23
|
-
#include "romfile.h" // romfile_loadint
|
|
24
|
-
#include "string.h" // memset
|
|
25
|
-
#include "util.h" // pci_setup
|
|
26
|
-
#include "x86.h" // outb
|
|
27
|
-
|
|
28
|
-
#define PCI_DEVICE_MEM_MIN (1<<12) // 4k == page size
|
|
29
|
-
#define PCI_BRIDGE_MEM_MIN (1<<21) // 2M == hugepage size
|
|
30
|
-
#define PCI_BRIDGE_IO_MIN 0x1000 // mandated by pci bridge spec
|
|
31
|
-
|
|
32
|
-
#define PCI_ROM_SLOT 6
|
|
33
|
-
#define PCI_NUM_REGIONS 7
|
|
34
|
-
#define PCI_BRIDGE_NUM_REGIONS 2
|
|
35
|
-
|
|
36
|
-
enum pci_region_type {
|
|
37
|
-
PCI_REGION_TYPE_IO,
|
|
38
|
-
PCI_REGION_TYPE_MEM,
|
|
39
|
-
PCI_REGION_TYPE_PREFMEM,
|
|
40
|
-
PCI_REGION_TYPE_COUNT,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
static const char *region_type_name[] = {
|
|
44
|
-
[ PCI_REGION_TYPE_IO ] = "io",
|
|
45
|
-
[ PCI_REGION_TYPE_MEM ] = "mem",
|
|
46
|
-
[ PCI_REGION_TYPE_PREFMEM ] = "prefmem",
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
u64 pcimem_start = BUILD_PCIMEM_START;
|
|
50
|
-
u64 pcimem_end = BUILD_PCIMEM_END;
|
|
51
|
-
u64 pcimem64_start = BUILD_PCIMEM64_START;
|
|
52
|
-
u64 pcimem64_end = BUILD_PCIMEM64_END;
|
|
53
|
-
u64 pci_io_low_end = 0xa000;
|
|
54
|
-
|
|
55
|
-
struct pci_region_entry {
|
|
56
|
-
struct pci_device *dev;
|
|
57
|
-
int bar;
|
|
58
|
-
u64 size;
|
|
59
|
-
u64 align;
|
|
60
|
-
int is64;
|
|
61
|
-
enum pci_region_type type;
|
|
62
|
-
struct hlist_node node;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
struct pci_region {
|
|
66
|
-
/* pci region assignments */
|
|
67
|
-
u64 base;
|
|
68
|
-
struct hlist_head list;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
struct pci_bus {
|
|
72
|
-
struct pci_region r[PCI_REGION_TYPE_COUNT];
|
|
73
|
-
struct pci_device *bus_dev;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
static u32 pci_bar(struct pci_device *pci, int region_num)
|
|
77
|
-
{
|
|
78
|
-
if (region_num != PCI_ROM_SLOT) {
|
|
79
|
-
return PCI_BASE_ADDRESS_0 + region_num * 4;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
#define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80
|
|
83
|
-
u8 type = pci->header_type & ~PCI_HEADER_TYPE_MULTI_FUNCTION;
|
|
84
|
-
return type == PCI_HEADER_TYPE_BRIDGE ? PCI_ROM_ADDRESS1 : PCI_ROM_ADDRESS;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static void
|
|
88
|
-
pci_set_io_region_addr(struct pci_device *pci, int bar, u64 addr, int is64)
|
|
89
|
-
{
|
|
90
|
-
u32 ofs = pci_bar(pci, bar);
|
|
91
|
-
pci_config_writel(pci->bdf, ofs, addr);
|
|
92
|
-
if (is64)
|
|
93
|
-
pci_config_writel(pci->bdf, ofs + 4, addr >> 32);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/****************************************************************
|
|
98
|
-
* Misc. device init
|
|
99
|
-
****************************************************************/
|
|
100
|
-
|
|
101
|
-
/* host irqs corresponding to PCI irqs A-D */
|
|
102
|
-
const u8 pci_irqs[4] = {
|
|
103
|
-
10, 10, 11, 11
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
static int dummy_pci_slot_get_irq(struct pci_device *pci, int pin)
|
|
107
|
-
{
|
|
108
|
-
dprintf(1, "pci_slot_get_irq called with unknown routing\n");
|
|
109
|
-
|
|
110
|
-
return 0xff; /* PCI defined "unknown" or "no connection" for x86 */
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
static int (*pci_slot_get_irq)(struct pci_device *pci, int pin) =
|
|
114
|
-
dummy_pci_slot_get_irq;
|
|
115
|
-
|
|
116
|
-
// Return the global irq number corresponding to a host bus device irq pin.
|
|
117
|
-
static int piix_pci_slot_get_irq(struct pci_device *pci, int pin)
|
|
118
|
-
{
|
|
119
|
-
int slot_addend = 0;
|
|
120
|
-
|
|
121
|
-
while (pci->parent != NULL) {
|
|
122
|
-
slot_addend += pci_bdf_to_dev(pci->bdf);
|
|
123
|
-
pci = pci->parent;
|
|
124
|
-
}
|
|
125
|
-
slot_addend += pci_bdf_to_dev(pci->bdf) - 1;
|
|
126
|
-
return pci_irqs[(pin - 1 + slot_addend) & 3];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
static int mch_pci_slot_get_irq(struct pci_device *pci, int pin)
|
|
130
|
-
{
|
|
131
|
-
int pin_addend = 0;
|
|
132
|
-
while (pci->parent != NULL) {
|
|
133
|
-
pin_addend += pci_bdf_to_dev(pci->bdf);
|
|
134
|
-
pci = pci->parent;
|
|
135
|
-
}
|
|
136
|
-
u8 slot = pci_bdf_to_dev(pci->bdf);
|
|
137
|
-
if (slot <= 24)
|
|
138
|
-
/* Slots 0-24 rotate slot:pin mapping similar to piix above, but
|
|
139
|
-
with a different starting index - see q35-acpi-dsdt.dsl */
|
|
140
|
-
return pci_irqs[(pin - 1 + pin_addend + slot) & 3];
|
|
141
|
-
/* Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H) */
|
|
142
|
-
return pci_irqs[(pin - 1 + pin_addend) & 3];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/* PIIX3/PIIX4 PCI to ISA bridge */
|
|
146
|
-
static void piix_isa_bridge_setup(struct pci_device *pci, void *arg)
|
|
147
|
-
{
|
|
148
|
-
int i, irq;
|
|
149
|
-
u8 elcr[2];
|
|
150
|
-
|
|
151
|
-
elcr[0] = 0x00;
|
|
152
|
-
elcr[1] = 0x00;
|
|
153
|
-
for (i = 0; i < 4; i++) {
|
|
154
|
-
irq = pci_irqs[i];
|
|
155
|
-
/* set to trigger level */
|
|
156
|
-
elcr[irq >> 3] |= (1 << (irq & 7));
|
|
157
|
-
/* activate irq remapping in PIIX */
|
|
158
|
-
pci_config_writeb(pci->bdf, 0x60 + i, irq);
|
|
159
|
-
}
|
|
160
|
-
outb(elcr[0], PIIX_PORT_ELCR1);
|
|
161
|
-
outb(elcr[1], PIIX_PORT_ELCR2);
|
|
162
|
-
dprintf(1, "PIIX3/PIIX4 init: elcr=%02x %02x\n", elcr[0], elcr[1]);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
static void mch_isa_lpc_setup(u16 bdf)
|
|
166
|
-
{
|
|
167
|
-
/* pm io base */
|
|
168
|
-
pci_config_writel(bdf, ICH9_LPC_PMBASE,
|
|
169
|
-
acpi_pm_base | ICH9_LPC_PMBASE_RTE);
|
|
170
|
-
|
|
171
|
-
/* acpi enable, SCI: IRQ9 000b = irq9*/
|
|
172
|
-
pci_config_writeb(bdf, ICH9_LPC_ACPI_CTRL, ICH9_LPC_ACPI_CTRL_ACPI_EN);
|
|
173
|
-
|
|
174
|
-
/* set root complex register block BAR */
|
|
175
|
-
pci_config_writel(bdf, ICH9_LPC_RCBA,
|
|
176
|
-
ICH9_LPC_RCBA_ADDR | ICH9_LPC_RCBA_EN);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
static int ICH9LpcBDF = -1;
|
|
180
|
-
|
|
181
|
-
/* ICH9 LPC PCI to ISA bridge */
|
|
182
|
-
/* PCI_VENDOR_ID_INTEL && PCI_DEVICE_ID_INTEL_ICH9_LPC */
|
|
183
|
-
static void mch_isa_bridge_setup(struct pci_device *dev, void *arg)
|
|
184
|
-
{
|
|
185
|
-
u16 bdf = dev->bdf;
|
|
186
|
-
int i, irq;
|
|
187
|
-
u8 elcr[2];
|
|
188
|
-
|
|
189
|
-
elcr[0] = 0x00;
|
|
190
|
-
elcr[1] = 0x00;
|
|
191
|
-
|
|
192
|
-
for (i = 0; i < 4; i++) {
|
|
193
|
-
irq = pci_irqs[i];
|
|
194
|
-
/* set to trigger level */
|
|
195
|
-
elcr[irq >> 3] |= (1 << (irq & 7));
|
|
196
|
-
|
|
197
|
-
/* activate irq remapping in LPC */
|
|
198
|
-
|
|
199
|
-
/* PIRQ[A-D] routing */
|
|
200
|
-
pci_config_writeb(bdf, ICH9_LPC_PIRQA_ROUT + i, irq);
|
|
201
|
-
/* PIRQ[E-H] routing */
|
|
202
|
-
pci_config_writeb(bdf, ICH9_LPC_PIRQE_ROUT + i, irq);
|
|
203
|
-
}
|
|
204
|
-
outb(elcr[0], ICH9_LPC_PORT_ELCR1);
|
|
205
|
-
outb(elcr[1], ICH9_LPC_PORT_ELCR2);
|
|
206
|
-
dprintf(1, "Q35 LPC init: elcr=%02x %02x\n", elcr[0], elcr[1]);
|
|
207
|
-
|
|
208
|
-
ICH9LpcBDF = bdf;
|
|
209
|
-
|
|
210
|
-
mch_isa_lpc_setup(bdf);
|
|
211
|
-
|
|
212
|
-
e820_add(ICH9_LPC_RCBA_ADDR, 16*1024, E820_RESERVED);
|
|
213
|
-
|
|
214
|
-
acpi_pm1a_cnt = acpi_pm_base + 0x04;
|
|
215
|
-
pmtimer_setup(acpi_pm_base + 0x08);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
static void storage_ide_setup(struct pci_device *pci, void *arg)
|
|
219
|
-
{
|
|
220
|
-
/* IDE: we map it as in ISA mode */
|
|
221
|
-
pci_set_io_region_addr(pci, 0, PORT_ATA1_CMD_BASE, 0);
|
|
222
|
-
pci_set_io_region_addr(pci, 1, PORT_ATA1_CTRL_BASE, 0);
|
|
223
|
-
pci_set_io_region_addr(pci, 2, PORT_ATA2_CMD_BASE, 0);
|
|
224
|
-
pci_set_io_region_addr(pci, 3, PORT_ATA2_CTRL_BASE, 0);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/* PIIX3/PIIX4 IDE */
|
|
228
|
-
static void piix_ide_setup(struct pci_device *pci, void *arg)
|
|
229
|
-
{
|
|
230
|
-
u16 bdf = pci->bdf;
|
|
231
|
-
pci_config_writew(bdf, 0x40, 0x8000); // enable IDE0
|
|
232
|
-
pci_config_writew(bdf, 0x42, 0x8000); // enable IDE1
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
static void pic_ibm_setup(struct pci_device *pci, void *arg)
|
|
236
|
-
{
|
|
237
|
-
/* PIC, IBM, MPIC & MPIC2 */
|
|
238
|
-
pci_set_io_region_addr(pci, 0, 0x80800000 + 0x00040000, 0);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
static void apple_macio_setup(struct pci_device *pci, void *arg)
|
|
242
|
-
{
|
|
243
|
-
/* macio bridge */
|
|
244
|
-
pci_set_io_region_addr(pci, 0, 0x80800000, 0);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
static void piix4_pm_config_setup(u16 bdf)
|
|
248
|
-
{
|
|
249
|
-
// acpi sci is hardwired to 9
|
|
250
|
-
pci_config_writeb(bdf, PCI_INTERRUPT_LINE, 9);
|
|
251
|
-
|
|
252
|
-
pci_config_writel(bdf, PIIX_PMBASE, acpi_pm_base | 1);
|
|
253
|
-
pci_config_writeb(bdf, PIIX_PMREGMISC, 0x01); /* enable PM io space */
|
|
254
|
-
pci_config_writel(bdf, PIIX_SMBHSTBASE, (acpi_pm_base + 0x100) | 1);
|
|
255
|
-
pci_config_writeb(bdf, PIIX_SMBHSTCFG, 0x09); /* enable SMBus io space */
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
static int PiixPmBDF = -1;
|
|
259
|
-
|
|
260
|
-
/* PIIX4 Power Management device (for ACPI) */
|
|
261
|
-
static void piix4_pm_setup(struct pci_device *pci, void *arg)
|
|
262
|
-
{
|
|
263
|
-
PiixPmBDF = pci->bdf;
|
|
264
|
-
piix4_pm_config_setup(pci->bdf);
|
|
265
|
-
|
|
266
|
-
acpi_pm1a_cnt = acpi_pm_base + 0x04;
|
|
267
|
-
pmtimer_setup(acpi_pm_base + 0x08);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
static void ich9_smbus_enable(u16 bdf)
|
|
271
|
-
{
|
|
272
|
-
/* map smbus into io space */
|
|
273
|
-
pci_config_writel(bdf, ICH9_SMB_SMB_BASE,
|
|
274
|
-
(acpi_pm_base + 0x100) | PCI_BASE_ADDRESS_SPACE_IO);
|
|
275
|
-
|
|
276
|
-
/* enable SMBus */
|
|
277
|
-
pci_config_writeb(bdf, ICH9_SMB_HOSTC, ICH9_SMB_HOSTC_HST_EN);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
static int ICH9SmbusBDF = -1;
|
|
281
|
-
|
|
282
|
-
/* ICH9 SMBUS */
|
|
283
|
-
/* PCI_VENDOR_ID_INTEL && PCI_DEVICE_ID_INTEL_ICH9_SMBUS */
|
|
284
|
-
static void ich9_smbus_setup(struct pci_device *dev, void *arg)
|
|
285
|
-
{
|
|
286
|
-
ICH9SmbusBDF = dev->bdf;
|
|
287
|
-
|
|
288
|
-
ich9_smbus_enable(dev->bdf);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
static void intel_igd_setup(struct pci_device *dev, void *arg)
|
|
292
|
-
{
|
|
293
|
-
struct romfile_s *opregion = romfile_find("etc/igd-opregion");
|
|
294
|
-
u64 bdsm_size = le64_to_cpu(romfile_loadint("etc/igd-bdsm-size", 0));
|
|
295
|
-
void *addr;
|
|
296
|
-
u16 bdf = dev->bdf;
|
|
297
|
-
|
|
298
|
-
/* Apply OpRegion to any Intel VGA device, more than one is undefined */
|
|
299
|
-
if (opregion && opregion->size) {
|
|
300
|
-
addr = memalign_high(PAGE_SIZE, opregion->size);
|
|
301
|
-
if (!addr) {
|
|
302
|
-
warn_noalloc();
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (opregion->copy(opregion, addr, opregion->size) < 0) {
|
|
307
|
-
free(addr);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
pci_config_writel(bdf, 0xFC, cpu_to_le32((u32)addr));
|
|
312
|
-
|
|
313
|
-
dprintf(1, "Intel IGD OpRegion enabled at 0x%08x, size %dKB, dev "
|
|
314
|
-
"%02x:%02x.%x\n", (u32)addr, opregion->size >> 10,
|
|
315
|
-
pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf));
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/* Apply BDSM only to Intel VGA at 00:02.0 */
|
|
319
|
-
if (bdsm_size && (bdf == pci_to_bdf(0, 2, 0))) {
|
|
320
|
-
addr = memalign_tmphigh(1024 * 1024, bdsm_size);
|
|
321
|
-
if (!addr) {
|
|
322
|
-
warn_noalloc();
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
e820_add((u32)addr, bdsm_size, E820_RESERVED);
|
|
327
|
-
|
|
328
|
-
pci_config_writel(bdf, 0x5C, cpu_to_le32((u32)addr));
|
|
329
|
-
|
|
330
|
-
dprintf(1, "Intel IGD BDSM enabled at 0x%08x, size %lldMB, dev "
|
|
331
|
-
"00:02.0\n", (u32)addr, bdsm_size >> 20);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
static const struct pci_device_id pci_device_tbl[] = {
|
|
336
|
-
/* PIIX3/PIIX4 PCI to ISA bridge */
|
|
337
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0,
|
|
338
|
-
piix_isa_bridge_setup),
|
|
339
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0,
|
|
340
|
-
piix_isa_bridge_setup),
|
|
341
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_LPC,
|
|
342
|
-
mch_isa_bridge_setup),
|
|
343
|
-
|
|
344
|
-
/* STORAGE IDE */
|
|
345
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_1,
|
|
346
|
-
PCI_CLASS_STORAGE_IDE, piix_ide_setup),
|
|
347
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB,
|
|
348
|
-
PCI_CLASS_STORAGE_IDE, piix_ide_setup),
|
|
349
|
-
PCI_DEVICE_CLASS(PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE,
|
|
350
|
-
storage_ide_setup),
|
|
351
|
-
|
|
352
|
-
/* PIC, IBM, MPIC & MPIC2 */
|
|
353
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_IBM, 0x0046, PCI_CLASS_SYSTEM_PIC,
|
|
354
|
-
pic_ibm_setup),
|
|
355
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_IBM, 0xFFFF, PCI_CLASS_SYSTEM_PIC,
|
|
356
|
-
pic_ibm_setup),
|
|
357
|
-
|
|
358
|
-
/* PIIX4 Power Management device (for ACPI) */
|
|
359
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3,
|
|
360
|
-
piix4_pm_setup),
|
|
361
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_SMBUS,
|
|
362
|
-
ich9_smbus_setup),
|
|
363
|
-
|
|
364
|
-
/* 0xff00 */
|
|
365
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_APPLE, 0x0017, 0xff00, apple_macio_setup),
|
|
366
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_APPLE, 0x0022, 0xff00, apple_macio_setup),
|
|
367
|
-
|
|
368
|
-
/* Intel IGD OpRegion setup */
|
|
369
|
-
PCI_DEVICE_CLASS(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA,
|
|
370
|
-
intel_igd_setup),
|
|
371
|
-
|
|
372
|
-
PCI_DEVICE_END,
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
static int MCHMmcfgBDF = -1;
|
|
376
|
-
static void mch_mmconfig_setup(u16 bdf);
|
|
377
|
-
|
|
378
|
-
void pci_resume(void)
|
|
379
|
-
{
|
|
380
|
-
if (!CONFIG_QEMU) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (PiixPmBDF >= 0) {
|
|
385
|
-
piix4_pm_config_setup(PiixPmBDF);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (ICH9LpcBDF >= 0) {
|
|
389
|
-
mch_isa_lpc_setup(ICH9LpcBDF);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
if (ICH9SmbusBDF >= 0) {
|
|
393
|
-
ich9_smbus_enable(ICH9SmbusBDF);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if(MCHMmcfgBDF >= 0) {
|
|
397
|
-
mch_mmconfig_setup(MCHMmcfgBDF);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
static void pci_bios_init_device(struct pci_device *pci)
|
|
402
|
-
{
|
|
403
|
-
dprintf(1, "PCI: init bdf=%pP id=%04x:%04x\n"
|
|
404
|
-
, pci, pci->vendor, pci->device);
|
|
405
|
-
|
|
406
|
-
/* map the interrupt */
|
|
407
|
-
u16 bdf = pci->bdf;
|
|
408
|
-
int pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN);
|
|
409
|
-
if (pin != 0)
|
|
410
|
-
pci_config_writeb(bdf, PCI_INTERRUPT_LINE, pci_slot_get_irq(pci, pin));
|
|
411
|
-
|
|
412
|
-
pci_init_device(pci_device_tbl, pci, NULL);
|
|
413
|
-
|
|
414
|
-
/* enable memory mappings */
|
|
415
|
-
pci_config_maskw(bdf, PCI_COMMAND, 0,
|
|
416
|
-
PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_SERR);
|
|
417
|
-
/* enable SERR# for forwarding */
|
|
418
|
-
if (pci->header_type & PCI_HEADER_TYPE_BRIDGE)
|
|
419
|
-
pci_config_maskw(bdf, PCI_BRIDGE_CONTROL, 0,
|
|
420
|
-
PCI_BRIDGE_CTL_SERR);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
static void pci_bios_init_devices(void)
|
|
424
|
-
{
|
|
425
|
-
struct pci_device *pci;
|
|
426
|
-
foreachpci(pci) {
|
|
427
|
-
pci_bios_init_device(pci);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
static void pci_enable_default_vga(void)
|
|
432
|
-
{
|
|
433
|
-
struct pci_device *pci;
|
|
434
|
-
|
|
435
|
-
foreachpci(pci) {
|
|
436
|
-
if (is_pci_vga(pci)) {
|
|
437
|
-
dprintf(1, "PCI: Using %pP for primary VGA\n", pci);
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
pci = pci_find_class(PCI_CLASS_DISPLAY_VGA);
|
|
443
|
-
if (!pci) {
|
|
444
|
-
dprintf(1, "PCI: No VGA devices found\n");
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
dprintf(1, "PCI: Enabling %pP for primary VGA\n", pci);
|
|
449
|
-
|
|
450
|
-
pci_config_maskw(pci->bdf, PCI_COMMAND, 0,
|
|
451
|
-
PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
|
|
452
|
-
|
|
453
|
-
while (pci->parent) {
|
|
454
|
-
pci = pci->parent;
|
|
455
|
-
|
|
456
|
-
dprintf(1, "PCI: Setting VGA enable on bridge %pP\n", pci);
|
|
457
|
-
|
|
458
|
-
pci_config_maskw(pci->bdf, PCI_BRIDGE_CONTROL, 0, PCI_BRIDGE_CTL_VGA);
|
|
459
|
-
pci_config_maskw(pci->bdf, PCI_COMMAND, 0,
|
|
460
|
-
PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/****************************************************************
|
|
465
|
-
* Platform device initialization
|
|
466
|
-
****************************************************************/
|
|
467
|
-
|
|
468
|
-
static void i440fx_mem_addr_setup(struct pci_device *dev, void *arg)
|
|
469
|
-
{
|
|
470
|
-
if (RamSize <= 0x80000000)
|
|
471
|
-
pcimem_start = 0x80000000;
|
|
472
|
-
else if (RamSize <= 0xc0000000)
|
|
473
|
-
pcimem_start = 0xc0000000;
|
|
474
|
-
|
|
475
|
-
pci_slot_get_irq = piix_pci_slot_get_irq;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
static void mch_mmconfig_setup(u16 bdf)
|
|
479
|
-
{
|
|
480
|
-
u64 addr = Q35_HOST_BRIDGE_PCIEXBAR_ADDR;
|
|
481
|
-
u32 upper = addr >> 32;
|
|
482
|
-
u32 lower = (addr & 0xffffffff) | Q35_HOST_BRIDGE_PCIEXBAREN;
|
|
483
|
-
pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR, 0);
|
|
484
|
-
pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR + 4, upper);
|
|
485
|
-
pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR, lower);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
static void mch_mem_addr_setup(struct pci_device *dev, void *arg)
|
|
489
|
-
{
|
|
490
|
-
u64 addr = Q35_HOST_BRIDGE_PCIEXBAR_ADDR;
|
|
491
|
-
u32 size = Q35_HOST_BRIDGE_PCIEXBAR_SIZE;
|
|
492
|
-
|
|
493
|
-
/* setup mmconfig */
|
|
494
|
-
MCHMmcfgBDF = dev->bdf;
|
|
495
|
-
mch_mmconfig_setup(dev->bdf);
|
|
496
|
-
e820_add(addr, size, E820_RESERVED);
|
|
497
|
-
|
|
498
|
-
/* setup pci i/o window (above mmconfig) */
|
|
499
|
-
pcimem_start = addr + size;
|
|
500
|
-
|
|
501
|
-
pci_slot_get_irq = mch_pci_slot_get_irq;
|
|
502
|
-
|
|
503
|
-
/* setup io address space */
|
|
504
|
-
if (acpi_pm_base < 0x1000)
|
|
505
|
-
pci_io_low_end = 0x10000;
|
|
506
|
-
else
|
|
507
|
-
pci_io_low_end = acpi_pm_base;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
static const struct pci_device_id pci_platform_tbl[] = {
|
|
511
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441,
|
|
512
|
-
i440fx_mem_addr_setup),
|
|
513
|
-
PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_Q35_MCH,
|
|
514
|
-
mch_mem_addr_setup),
|
|
515
|
-
PCI_DEVICE_END
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
static void pci_bios_init_platform(void)
|
|
519
|
-
{
|
|
520
|
-
struct pci_device *pci;
|
|
521
|
-
foreachpci(pci) {
|
|
522
|
-
pci_init_device(pci_platform_tbl, pci, NULL);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
static u8 pci_find_resource_reserve_capability(u16 bdf)
|
|
527
|
-
{
|
|
528
|
-
u16 device_id;
|
|
529
|
-
|
|
530
|
-
if (pci_config_readw(bdf, PCI_VENDOR_ID) != PCI_VENDOR_ID_REDHAT) {
|
|
531
|
-
dprintf(3, "PCI: This is non-QEMU bridge.\n");
|
|
532
|
-
return 0;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
device_id = pci_config_readw(bdf, PCI_DEVICE_ID);
|
|
536
|
-
|
|
537
|
-
if (device_id != PCI_DEVICE_ID_REDHAT_ROOT_PORT &&
|
|
538
|
-
device_id != PCI_DEVICE_ID_REDHAT_BRIDGE) {
|
|
539
|
-
dprintf(1, "PCI: QEMU resource reserve cap device ID doesn't match.\n");
|
|
540
|
-
return 0;
|
|
541
|
-
}
|
|
542
|
-
u8 cap = 0;
|
|
543
|
-
|
|
544
|
-
do {
|
|
545
|
-
cap = pci_find_capability(bdf, PCI_CAP_ID_VNDR, cap);
|
|
546
|
-
} while (cap &&
|
|
547
|
-
pci_config_readb(bdf, cap + PCI_CAP_REDHAT_TYPE_OFFSET) !=
|
|
548
|
-
REDHAT_CAP_RESOURCE_RESERVE);
|
|
549
|
-
if (cap) {
|
|
550
|
-
u8 cap_len = pci_config_readb(bdf, cap + PCI_CAP_FLAGS);
|
|
551
|
-
if (cap_len < RES_RESERVE_CAP_SIZE) {
|
|
552
|
-
dprintf(1, "PCI: QEMU resource reserve cap length %d is invalid\n",
|
|
553
|
-
cap_len);
|
|
554
|
-
return 0;
|
|
555
|
-
}
|
|
556
|
-
} else {
|
|
557
|
-
dprintf(1, "PCI: QEMU resource reserve cap not found\n");
|
|
558
|
-
}
|
|
559
|
-
return cap;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
/****************************************************************
|
|
563
|
-
* Bus initialization
|
|
564
|
-
****************************************************************/
|
|
565
|
-
|
|
566
|
-
static void
|
|
567
|
-
pci_bios_init_bus_rec(int bus, u8 *pci_bus)
|
|
568
|
-
{
|
|
569
|
-
int bdf;
|
|
570
|
-
u16 class;
|
|
571
|
-
|
|
572
|
-
dprintf(1, "PCI: %s bus = 0x%x\n", __func__, bus);
|
|
573
|
-
|
|
574
|
-
/* prevent accidental access to unintended devices */
|
|
575
|
-
foreachbdf(bdf, bus) {
|
|
576
|
-
class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
|
|
577
|
-
if (class == PCI_CLASS_BRIDGE_PCI) {
|
|
578
|
-
pci_config_writeb(bdf, PCI_SECONDARY_BUS, 255);
|
|
579
|
-
pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, 0);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
foreachbdf(bdf, bus) {
|
|
584
|
-
class = pci_config_readw(bdf, PCI_CLASS_DEVICE);
|
|
585
|
-
if (class != PCI_CLASS_BRIDGE_PCI) {
|
|
586
|
-
continue;
|
|
587
|
-
}
|
|
588
|
-
dprintf(1, "PCI: %s bdf = 0x%x\n", __func__, bdf);
|
|
589
|
-
|
|
590
|
-
u8 pribus = pci_config_readb(bdf, PCI_PRIMARY_BUS);
|
|
591
|
-
if (pribus != bus) {
|
|
592
|
-
dprintf(1, "PCI: primary bus = 0x%x -> 0x%x\n", pribus, bus);
|
|
593
|
-
pci_config_writeb(bdf, PCI_PRIMARY_BUS, bus);
|
|
594
|
-
} else {
|
|
595
|
-
dprintf(1, "PCI: primary bus = 0x%x\n", pribus);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
u8 secbus = pci_config_readb(bdf, PCI_SECONDARY_BUS);
|
|
599
|
-
(*pci_bus)++;
|
|
600
|
-
if (*pci_bus != secbus) {
|
|
601
|
-
dprintf(1, "PCI: secondary bus = 0x%x -> 0x%x\n",
|
|
602
|
-
secbus, *pci_bus);
|
|
603
|
-
secbus = *pci_bus;
|
|
604
|
-
pci_config_writeb(bdf, PCI_SECONDARY_BUS, secbus);
|
|
605
|
-
} else {
|
|
606
|
-
dprintf(1, "PCI: secondary bus = 0x%x\n", secbus);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/* set to max for access to all subordinate buses.
|
|
610
|
-
later set it to accurate value */
|
|
611
|
-
u8 subbus = pci_config_readb(bdf, PCI_SUBORDINATE_BUS);
|
|
612
|
-
pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, 255);
|
|
613
|
-
|
|
614
|
-
pci_bios_init_bus_rec(secbus, pci_bus);
|
|
615
|
-
|
|
616
|
-
if (subbus != *pci_bus) {
|
|
617
|
-
u8 res_bus = *pci_bus;
|
|
618
|
-
u8 cap = pci_find_resource_reserve_capability(bdf);
|
|
619
|
-
|
|
620
|
-
if (cap) {
|
|
621
|
-
u32 tmp_res_bus = pci_config_readl(bdf,
|
|
622
|
-
cap + RES_RESERVE_BUS_RES);
|
|
623
|
-
if (tmp_res_bus != (u32)-1) {
|
|
624
|
-
res_bus = tmp_res_bus & 0xFF;
|
|
625
|
-
if ((u8)(res_bus + secbus) < secbus ||
|
|
626
|
-
(u8)(res_bus + secbus) < res_bus) {
|
|
627
|
-
dprintf(1, "PCI: bus_reserve value %d is invalid\n",
|
|
628
|
-
res_bus);
|
|
629
|
-
res_bus = 0;
|
|
630
|
-
}
|
|
631
|
-
if (secbus + res_bus > *pci_bus) {
|
|
632
|
-
dprintf(1, "PCI: QEMU resource reserve cap: bus = %u\n",
|
|
633
|
-
res_bus);
|
|
634
|
-
res_bus = secbus + res_bus;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
dprintf(1, "PCI: subordinate bus = 0x%x -> 0x%x\n",
|
|
639
|
-
subbus, res_bus);
|
|
640
|
-
subbus = res_bus;
|
|
641
|
-
*pci_bus = res_bus;
|
|
642
|
-
} else {
|
|
643
|
-
dprintf(1, "PCI: subordinate bus = 0x%x\n", subbus);
|
|
644
|
-
}
|
|
645
|
-
pci_config_writeb(bdf, PCI_SUBORDINATE_BUS, subbus);
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
static void
|
|
650
|
-
pci_bios_init_bus(void)
|
|
651
|
-
{
|
|
652
|
-
u8 extraroots = romfile_loadint("etc/extra-pci-roots", 0);
|
|
653
|
-
u8 pci_bus = 0;
|
|
654
|
-
|
|
655
|
-
pci_bios_init_bus_rec(0 /* host bus */, &pci_bus);
|
|
656
|
-
|
|
657
|
-
if (extraroots) {
|
|
658
|
-
while (pci_bus < 0xff) {
|
|
659
|
-
pci_bus++;
|
|
660
|
-
pci_bios_init_bus_rec(pci_bus, &pci_bus);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
/****************************************************************
|
|
667
|
-
* Bus sizing
|
|
668
|
-
****************************************************************/
|
|
669
|
-
|
|
670
|
-
static void
|
|
671
|
-
pci_bios_get_bar(struct pci_device *pci, int bar,
|
|
672
|
-
int *ptype, u64 *psize, int *pis64)
|
|
673
|
-
{
|
|
674
|
-
u32 ofs = pci_bar(pci, bar);
|
|
675
|
-
u16 bdf = pci->bdf;
|
|
676
|
-
u32 old = pci_config_readl(bdf, ofs);
|
|
677
|
-
int is64 = 0, type = PCI_REGION_TYPE_MEM;
|
|
678
|
-
u64 mask;
|
|
679
|
-
|
|
680
|
-
if (bar == PCI_ROM_SLOT) {
|
|
681
|
-
mask = PCI_ROM_ADDRESS_MASK;
|
|
682
|
-
pci_config_writel(bdf, ofs, mask);
|
|
683
|
-
} else {
|
|
684
|
-
if (old & PCI_BASE_ADDRESS_SPACE_IO) {
|
|
685
|
-
mask = PCI_BASE_ADDRESS_IO_MASK;
|
|
686
|
-
type = PCI_REGION_TYPE_IO;
|
|
687
|
-
} else {
|
|
688
|
-
mask = PCI_BASE_ADDRESS_MEM_MASK;
|
|
689
|
-
if (old & PCI_BASE_ADDRESS_MEM_PREFETCH)
|
|
690
|
-
type = PCI_REGION_TYPE_PREFMEM;
|
|
691
|
-
is64 = ((old & PCI_BASE_ADDRESS_MEM_TYPE_MASK)
|
|
692
|
-
== PCI_BASE_ADDRESS_MEM_TYPE_64);
|
|
693
|
-
}
|
|
694
|
-
pci_config_writel(bdf, ofs, ~0);
|
|
695
|
-
}
|
|
696
|
-
u64 val = pci_config_readl(bdf, ofs);
|
|
697
|
-
pci_config_writel(bdf, ofs, old);
|
|
698
|
-
if (is64) {
|
|
699
|
-
u32 hold = pci_config_readl(bdf, ofs + 4);
|
|
700
|
-
pci_config_writel(bdf, ofs + 4, ~0);
|
|
701
|
-
u32 high = pci_config_readl(bdf, ofs + 4);
|
|
702
|
-
pci_config_writel(bdf, ofs + 4, hold);
|
|
703
|
-
val |= ((u64)high << 32);
|
|
704
|
-
mask |= ((u64)0xffffffff << 32);
|
|
705
|
-
*psize = (~(val & mask)) + 1;
|
|
706
|
-
} else {
|
|
707
|
-
*psize = ((~(val & mask)) + 1) & 0xffffffff;
|
|
708
|
-
}
|
|
709
|
-
*ptype = type;
|
|
710
|
-
*pis64 = is64;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
static int pci_bios_bridge_region_is64(struct pci_region *r,
|
|
714
|
-
struct pci_device *pci, int type)
|
|
715
|
-
{
|
|
716
|
-
if (type != PCI_REGION_TYPE_PREFMEM)
|
|
717
|
-
return 0;
|
|
718
|
-
u32 pmem = pci_config_readl(pci->bdf, PCI_PREF_MEMORY_BASE);
|
|
719
|
-
if (!pmem) {
|
|
720
|
-
pci_config_writel(pci->bdf, PCI_PREF_MEMORY_BASE, 0xfff0fff0);
|
|
721
|
-
pmem = pci_config_readl(pci->bdf, PCI_PREF_MEMORY_BASE);
|
|
722
|
-
pci_config_writel(pci->bdf, PCI_PREF_MEMORY_BASE, 0x0);
|
|
723
|
-
}
|
|
724
|
-
if ((pmem & PCI_PREF_RANGE_TYPE_MASK) != PCI_PREF_RANGE_TYPE_64)
|
|
725
|
-
return 0;
|
|
726
|
-
struct pci_region_entry *entry;
|
|
727
|
-
hlist_for_each_entry(entry, &r->list, node) {
|
|
728
|
-
if (!entry->is64)
|
|
729
|
-
return 0;
|
|
730
|
-
}
|
|
731
|
-
return 1;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
static u64 pci_region_align(struct pci_region *r)
|
|
735
|
-
{
|
|
736
|
-
struct pci_region_entry *entry;
|
|
737
|
-
hlist_for_each_entry(entry, &r->list, node) {
|
|
738
|
-
// The first entry in the sorted list has the largest alignment
|
|
739
|
-
return entry->align;
|
|
740
|
-
}
|
|
741
|
-
return 1;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
static u64 pci_region_sum(struct pci_region *r)
|
|
745
|
-
{
|
|
746
|
-
u64 sum = 0;
|
|
747
|
-
struct pci_region_entry *entry;
|
|
748
|
-
hlist_for_each_entry(entry, &r->list, node) {
|
|
749
|
-
sum += entry->size;
|
|
750
|
-
}
|
|
751
|
-
return sum;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
static void pci_region_migrate_64bit_entries(struct pci_region *from,
|
|
755
|
-
struct pci_region *to)
|
|
756
|
-
{
|
|
757
|
-
struct hlist_node *n, **last = &to->list.first;
|
|
758
|
-
struct pci_region_entry *entry;
|
|
759
|
-
hlist_for_each_entry_safe(entry, n, &from->list, node) {
|
|
760
|
-
if (!entry->is64)
|
|
761
|
-
continue;
|
|
762
|
-
if (entry->dev->class == PCI_CLASS_SERIAL_USB)
|
|
763
|
-
continue;
|
|
764
|
-
// Move from source list to destination list.
|
|
765
|
-
hlist_del(&entry->node);
|
|
766
|
-
hlist_add(&entry->node, last);
|
|
767
|
-
last = &entry->node.next;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
static struct pci_region_entry *
|
|
772
|
-
pci_region_create_entry(struct pci_bus *bus, struct pci_device *dev,
|
|
773
|
-
int bar, u64 size, u64 align, int type, int is64)
|
|
774
|
-
{
|
|
775
|
-
struct pci_region_entry *entry = malloc_tmp(sizeof(*entry));
|
|
776
|
-
if (!entry) {
|
|
777
|
-
warn_noalloc();
|
|
778
|
-
return NULL;
|
|
779
|
-
}
|
|
780
|
-
memset(entry, 0, sizeof(*entry));
|
|
781
|
-
entry->dev = dev;
|
|
782
|
-
entry->bar = bar;
|
|
783
|
-
entry->size = size;
|
|
784
|
-
entry->align = align;
|
|
785
|
-
entry->is64 = is64;
|
|
786
|
-
entry->type = type;
|
|
787
|
-
// Insert into list in sorted order.
|
|
788
|
-
struct hlist_node **pprev;
|
|
789
|
-
struct pci_region_entry *pos;
|
|
790
|
-
hlist_for_each_entry_pprev(pos, pprev, &bus->r[type].list, node) {
|
|
791
|
-
if (pos->align < align || (pos->align == align && pos->size < size))
|
|
792
|
-
break;
|
|
793
|
-
}
|
|
794
|
-
hlist_add(&entry->node, pprev);
|
|
795
|
-
return entry;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
static int pci_bus_hotplug_support(struct pci_bus *bus, u8 pcie_cap)
|
|
799
|
-
{
|
|
800
|
-
u8 shpc_cap;
|
|
801
|
-
|
|
802
|
-
if (pcie_cap) {
|
|
803
|
-
u16 pcie_flags = pci_config_readw(bus->bus_dev->bdf,
|
|
804
|
-
pcie_cap + PCI_EXP_FLAGS);
|
|
805
|
-
u8 port_type = ((pcie_flags & PCI_EXP_FLAGS_TYPE) >>
|
|
806
|
-
(__builtin_ffs(PCI_EXP_FLAGS_TYPE) - 1));
|
|
807
|
-
u8 downstream_port = (port_type == PCI_EXP_TYPE_DOWNSTREAM) ||
|
|
808
|
-
(port_type == PCI_EXP_TYPE_ROOT_PORT);
|
|
809
|
-
/*
|
|
810
|
-
* PCI Express SPEC, 7.8.2:
|
|
811
|
-
* Slot Implemented – When Set, this bit indicates that the Link
|
|
812
|
-
* HwInit associated with this Port is connected to a slot (as
|
|
813
|
-
* compared to being connected to a system-integrated device or
|
|
814
|
-
* being disabled).
|
|
815
|
-
* This bit is valid for Downstream Ports. This bit is undefined
|
|
816
|
-
* for Upstream Ports.
|
|
817
|
-
*/
|
|
818
|
-
u16 slot_implemented = pcie_flags & PCI_EXP_FLAGS_SLOT;
|
|
819
|
-
|
|
820
|
-
return downstream_port && slot_implemented;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
shpc_cap = pci_find_capability(bus->bus_dev->bdf, PCI_CAP_ID_SHPC, 0);
|
|
824
|
-
return !!shpc_cap;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
/* Test whether bridge support forwarding of transactions
|
|
828
|
-
* of a specific type.
|
|
829
|
-
* Note: disables bridge's window registers as a side effect.
|
|
830
|
-
*/
|
|
831
|
-
static int pci_bridge_has_region(struct pci_device *pci,
|
|
832
|
-
enum pci_region_type region_type)
|
|
833
|
-
{
|
|
834
|
-
u8 base;
|
|
835
|
-
|
|
836
|
-
switch (region_type) {
|
|
837
|
-
case PCI_REGION_TYPE_IO:
|
|
838
|
-
base = PCI_IO_BASE;
|
|
839
|
-
break;
|
|
840
|
-
case PCI_REGION_TYPE_PREFMEM:
|
|
841
|
-
base = PCI_PREF_MEMORY_BASE;
|
|
842
|
-
break;
|
|
843
|
-
default:
|
|
844
|
-
/* Regular memory support is mandatory */
|
|
845
|
-
return 1;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
pci_config_writeb(pci->bdf, base, 0xFF);
|
|
849
|
-
|
|
850
|
-
return pci_config_readb(pci->bdf, base) != 0;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
static int pci_bios_check_devices(struct pci_bus *busses)
|
|
854
|
-
{
|
|
855
|
-
dprintf(1, "PCI: check devices\n");
|
|
856
|
-
|
|
857
|
-
// Calculate resources needed for regular (non-bus) devices.
|
|
858
|
-
struct pci_device *pci;
|
|
859
|
-
foreachpci(pci) {
|
|
860
|
-
if (pci->class == PCI_CLASS_BRIDGE_PCI)
|
|
861
|
-
busses[pci->secondary_bus].bus_dev = pci;
|
|
862
|
-
|
|
863
|
-
struct pci_bus *bus = &busses[pci_bdf_to_bus(pci->bdf)];
|
|
864
|
-
if (!bus->bus_dev)
|
|
865
|
-
/*
|
|
866
|
-
* Resources for all root busses go in busses[0]
|
|
867
|
-
*/
|
|
868
|
-
bus = &busses[0];
|
|
869
|
-
int i;
|
|
870
|
-
for (i = 0; i < PCI_NUM_REGIONS; i++) {
|
|
871
|
-
if ((pci->class == PCI_CLASS_BRIDGE_PCI) &&
|
|
872
|
-
(i >= PCI_BRIDGE_NUM_REGIONS && i < PCI_ROM_SLOT))
|
|
873
|
-
continue;
|
|
874
|
-
int type, is64;
|
|
875
|
-
u64 size;
|
|
876
|
-
pci_bios_get_bar(pci, i, &type, &size, &is64);
|
|
877
|
-
if (size == 0)
|
|
878
|
-
continue;
|
|
879
|
-
|
|
880
|
-
if (type != PCI_REGION_TYPE_IO && size < PCI_DEVICE_MEM_MIN)
|
|
881
|
-
size = PCI_DEVICE_MEM_MIN;
|
|
882
|
-
struct pci_region_entry *entry = pci_region_create_entry(
|
|
883
|
-
bus, pci, i, size, size, type, is64);
|
|
884
|
-
if (!entry)
|
|
885
|
-
return -1;
|
|
886
|
-
|
|
887
|
-
if (is64)
|
|
888
|
-
i++;
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
// Propagate required bus resources to parent busses.
|
|
893
|
-
int secondary_bus;
|
|
894
|
-
for (secondary_bus=MaxPCIBus; secondary_bus>0; secondary_bus--) {
|
|
895
|
-
struct pci_bus *s = &busses[secondary_bus];
|
|
896
|
-
if (!s->bus_dev)
|
|
897
|
-
continue;
|
|
898
|
-
struct pci_bus *parent = &busses[pci_bdf_to_bus(s->bus_dev->bdf)];
|
|
899
|
-
if (!parent->bus_dev)
|
|
900
|
-
/*
|
|
901
|
-
* Resources for all root busses go in busses[0]
|
|
902
|
-
*/
|
|
903
|
-
parent = &busses[0];
|
|
904
|
-
int type;
|
|
905
|
-
u16 bdf = s->bus_dev->bdf;
|
|
906
|
-
u8 pcie_cap = pci_find_capability(bdf, PCI_CAP_ID_EXP, 0);
|
|
907
|
-
u8 qemu_cap = pci_find_resource_reserve_capability(bdf);
|
|
908
|
-
|
|
909
|
-
int hotplug_support = pci_bus_hotplug_support(s, pcie_cap);
|
|
910
|
-
for (type = 0; type < PCI_REGION_TYPE_COUNT; type++) {
|
|
911
|
-
u64 align = (type == PCI_REGION_TYPE_IO) ?
|
|
912
|
-
PCI_BRIDGE_IO_MIN : PCI_BRIDGE_MEM_MIN;
|
|
913
|
-
if (!pci_bridge_has_region(s->bus_dev, type))
|
|
914
|
-
continue;
|
|
915
|
-
u64 size = 0;
|
|
916
|
-
if (qemu_cap) {
|
|
917
|
-
u32 tmp_size;
|
|
918
|
-
u64 tmp_size_64;
|
|
919
|
-
switch(type) {
|
|
920
|
-
case PCI_REGION_TYPE_IO:
|
|
921
|
-
tmp_size_64 = (pci_config_readl(bdf, qemu_cap + RES_RESERVE_IO) |
|
|
922
|
-
(u64)pci_config_readl(bdf, qemu_cap + RES_RESERVE_IO + 4) << 32);
|
|
923
|
-
if (tmp_size_64 != (u64)-1) {
|
|
924
|
-
size = tmp_size_64;
|
|
925
|
-
}
|
|
926
|
-
break;
|
|
927
|
-
case PCI_REGION_TYPE_MEM:
|
|
928
|
-
tmp_size = pci_config_readl(bdf, qemu_cap + RES_RESERVE_MEM);
|
|
929
|
-
if (tmp_size != (u32)-1) {
|
|
930
|
-
size = tmp_size;
|
|
931
|
-
}
|
|
932
|
-
break;
|
|
933
|
-
case PCI_REGION_TYPE_PREFMEM:
|
|
934
|
-
tmp_size = pci_config_readl(bdf, qemu_cap + RES_RESERVE_PREF_MEM_32);
|
|
935
|
-
tmp_size_64 = (pci_config_readl(bdf, qemu_cap + RES_RESERVE_PREF_MEM_64) |
|
|
936
|
-
(u64)pci_config_readl(bdf, qemu_cap + RES_RESERVE_PREF_MEM_64 + 4) << 32);
|
|
937
|
-
if (tmp_size != (u32)-1 && tmp_size_64 == (u64)-1) {
|
|
938
|
-
size = tmp_size;
|
|
939
|
-
} else if (tmp_size == (u32)-1 && tmp_size_64 != (u64)-1) {
|
|
940
|
-
size = tmp_size_64;
|
|
941
|
-
} else if (tmp_size != (u32)-1 && tmp_size_64 != (u64)-1) {
|
|
942
|
-
dprintf(1, "PCI: resource reserve cap PREF32 and PREF64"
|
|
943
|
-
" conflict\n");
|
|
944
|
-
}
|
|
945
|
-
break;
|
|
946
|
-
default:
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
if (pci_region_align(&s->r[type]) > align)
|
|
951
|
-
align = pci_region_align(&s->r[type]);
|
|
952
|
-
u64 sum = pci_region_sum(&s->r[type]);
|
|
953
|
-
int resource_optional = pcie_cap && (type == PCI_REGION_TYPE_IO);
|
|
954
|
-
if (!sum && hotplug_support && !resource_optional)
|
|
955
|
-
sum = align; /* reserve min size for hot-plug */
|
|
956
|
-
if (size > sum) {
|
|
957
|
-
dprintf(1, "PCI: QEMU resource reserve cap: "
|
|
958
|
-
"size %08llx type %s\n",
|
|
959
|
-
size, region_type_name[type]);
|
|
960
|
-
if (type != PCI_REGION_TYPE_IO) {
|
|
961
|
-
size = ALIGN(size, align);
|
|
962
|
-
}
|
|
963
|
-
} else {
|
|
964
|
-
size = ALIGN(sum, align);
|
|
965
|
-
}
|
|
966
|
-
int is64 = pci_bios_bridge_region_is64(&s->r[type],
|
|
967
|
-
s->bus_dev, type);
|
|
968
|
-
// entry->bar is -1 if the entry represents a bridge region
|
|
969
|
-
struct pci_region_entry *entry = pci_region_create_entry(
|
|
970
|
-
parent, s->bus_dev, -1, size, align, type, is64);
|
|
971
|
-
if (!entry)
|
|
972
|
-
return -1;
|
|
973
|
-
dprintf(1, "PCI: secondary bus %d size %08llx type %s\n",
|
|
974
|
-
entry->dev->secondary_bus, size,
|
|
975
|
-
region_type_name[entry->type]);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
return 0;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
/****************************************************************
|
|
983
|
-
* BAR assignment
|
|
984
|
-
****************************************************************/
|
|
985
|
-
|
|
986
|
-
// Setup region bases (given the regions' size and alignment)
|
|
987
|
-
static int pci_bios_init_root_regions_io(struct pci_bus *bus)
|
|
988
|
-
{
|
|
989
|
-
/*
|
|
990
|
-
* QEMU I/O address space usage:
|
|
991
|
-
* 0000 - 0fff legacy isa, pci config, pci root bus, ...
|
|
992
|
-
* 1000 - 9fff free
|
|
993
|
-
* a000 - afff hotplug (cpu, pci via acpi, i440fx/piix only)
|
|
994
|
-
* b000 - bfff power management (PORT_ACPI_PM_BASE)
|
|
995
|
-
* [ qemu 1.4+ implements pci config registers
|
|
996
|
-
* properly so guests can place the registers
|
|
997
|
-
* where they want, on older versions its fixed ]
|
|
998
|
-
* c000 - ffff free, traditionally used for pci io
|
|
999
|
-
*/
|
|
1000
|
-
struct pci_region *r_io = &bus->r[PCI_REGION_TYPE_IO];
|
|
1001
|
-
u64 sum = pci_region_sum(r_io);
|
|
1002
|
-
if (sum < 0x4000) {
|
|
1003
|
-
/* traditional region is big enougth, use it */
|
|
1004
|
-
r_io->base = 0xc000;
|
|
1005
|
-
} else if (sum < pci_io_low_end - 0x1000) {
|
|
1006
|
-
/* use the larger region at 0x1000 */
|
|
1007
|
-
r_io->base = 0x1000;
|
|
1008
|
-
} else {
|
|
1009
|
-
/* not enouth io address space -> error out */
|
|
1010
|
-
return -1;
|
|
1011
|
-
}
|
|
1012
|
-
dprintf(1, "PCI: IO: %4llx - %4llx\n", r_io->base, r_io->base + sum - 1);
|
|
1013
|
-
return 0;
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
static int pci_bios_init_root_regions_mem(struct pci_bus *bus)
|
|
1017
|
-
{
|
|
1018
|
-
struct pci_region *r_end = &bus->r[PCI_REGION_TYPE_PREFMEM];
|
|
1019
|
-
struct pci_region *r_start = &bus->r[PCI_REGION_TYPE_MEM];
|
|
1020
|
-
|
|
1021
|
-
if (pci_region_align(r_start) < pci_region_align(r_end)) {
|
|
1022
|
-
// Swap regions to improve alignment.
|
|
1023
|
-
r_end = r_start;
|
|
1024
|
-
r_start = &bus->r[PCI_REGION_TYPE_PREFMEM];
|
|
1025
|
-
}
|
|
1026
|
-
u64 sum = pci_region_sum(r_end);
|
|
1027
|
-
u64 align = pci_region_align(r_end);
|
|
1028
|
-
r_end->base = ALIGN_DOWN((pcimem_end - sum), align);
|
|
1029
|
-
sum = pci_region_sum(r_start);
|
|
1030
|
-
align = pci_region_align(r_start);
|
|
1031
|
-
r_start->base = ALIGN_DOWN((r_end->base - sum), align);
|
|
1032
|
-
|
|
1033
|
-
if ((r_start->base < pcimem_start) ||
|
|
1034
|
-
(r_start->base > pcimem_end))
|
|
1035
|
-
// Memory range requested is larger than available.
|
|
1036
|
-
return -1;
|
|
1037
|
-
return 0;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
#define PCI_IO_SHIFT 8
|
|
1041
|
-
#define PCI_MEMORY_SHIFT 16
|
|
1042
|
-
#define PCI_PREF_MEMORY_SHIFT 16
|
|
1043
|
-
|
|
1044
|
-
static void
|
|
1045
|
-
pci_region_map_one_entry(struct pci_region_entry *entry, u64 addr)
|
|
1046
|
-
{
|
|
1047
|
-
if (entry->bar >= 0) {
|
|
1048
|
-
dprintf(1, "PCI: map device bdf=%pP"
|
|
1049
|
-
" bar %d, addr %08llx, size %08llx [%s]\n",
|
|
1050
|
-
entry->dev,
|
|
1051
|
-
entry->bar, addr, entry->size, region_type_name[entry->type]);
|
|
1052
|
-
|
|
1053
|
-
pci_set_io_region_addr(entry->dev, entry->bar, addr, entry->is64);
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
u16 bdf = entry->dev->bdf;
|
|
1058
|
-
u64 limit = addr + entry->size - 1;
|
|
1059
|
-
if (entry->type == PCI_REGION_TYPE_IO) {
|
|
1060
|
-
pci_config_writeb(bdf, PCI_IO_BASE, addr >> PCI_IO_SHIFT);
|
|
1061
|
-
pci_config_writew(bdf, PCI_IO_BASE_UPPER16, 0);
|
|
1062
|
-
pci_config_writeb(bdf, PCI_IO_LIMIT, limit >> PCI_IO_SHIFT);
|
|
1063
|
-
pci_config_writew(bdf, PCI_IO_LIMIT_UPPER16, 0);
|
|
1064
|
-
}
|
|
1065
|
-
if (entry->type == PCI_REGION_TYPE_MEM) {
|
|
1066
|
-
pci_config_writew(bdf, PCI_MEMORY_BASE, addr >> PCI_MEMORY_SHIFT);
|
|
1067
|
-
pci_config_writew(bdf, PCI_MEMORY_LIMIT, limit >> PCI_MEMORY_SHIFT);
|
|
1068
|
-
}
|
|
1069
|
-
if (entry->type == PCI_REGION_TYPE_PREFMEM) {
|
|
1070
|
-
pci_config_writew(bdf, PCI_PREF_MEMORY_BASE, addr >> PCI_PREF_MEMORY_SHIFT);
|
|
1071
|
-
pci_config_writew(bdf, PCI_PREF_MEMORY_LIMIT, limit >> PCI_PREF_MEMORY_SHIFT);
|
|
1072
|
-
pci_config_writel(bdf, PCI_PREF_BASE_UPPER32, addr >> 32);
|
|
1073
|
-
pci_config_writel(bdf, PCI_PREF_LIMIT_UPPER32, limit >> 32);
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r)
|
|
1078
|
-
{
|
|
1079
|
-
struct hlist_node *n;
|
|
1080
|
-
struct pci_region_entry *entry;
|
|
1081
|
-
hlist_for_each_entry_safe(entry, n, &r->list, node) {
|
|
1082
|
-
u64 addr = r->base;
|
|
1083
|
-
r->base += entry->size;
|
|
1084
|
-
if (entry->bar == -1)
|
|
1085
|
-
// Update bus base address if entry is a bridge region
|
|
1086
|
-
busses[entry->dev->secondary_bus].r[entry->type].base = addr;
|
|
1087
|
-
pci_region_map_one_entry(entry, addr);
|
|
1088
|
-
hlist_del(&entry->node);
|
|
1089
|
-
free(entry);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
static void pci_bios_map_devices(struct pci_bus *busses)
|
|
1094
|
-
{
|
|
1095
|
-
if (pci_bios_init_root_regions_io(busses))
|
|
1096
|
-
panic("PCI: out of I/O address space\n");
|
|
1097
|
-
|
|
1098
|
-
dprintf(1, "PCI: 32: %016llx - %016llx\n", pcimem_start, pcimem_end);
|
|
1099
|
-
if (pci_bios_init_root_regions_mem(busses)) {
|
|
1100
|
-
struct pci_region r64_mem, r64_pref;
|
|
1101
|
-
r64_mem.list.first = NULL;
|
|
1102
|
-
r64_pref.list.first = NULL;
|
|
1103
|
-
pci_region_migrate_64bit_entries(&busses[0].r[PCI_REGION_TYPE_MEM],
|
|
1104
|
-
&r64_mem);
|
|
1105
|
-
pci_region_migrate_64bit_entries(&busses[0].r[PCI_REGION_TYPE_PREFMEM],
|
|
1106
|
-
&r64_pref);
|
|
1107
|
-
|
|
1108
|
-
if (pci_bios_init_root_regions_mem(busses))
|
|
1109
|
-
panic("PCI: out of 32bit address space\n");
|
|
1110
|
-
|
|
1111
|
-
u64 sum_mem = pci_region_sum(&r64_mem);
|
|
1112
|
-
u64 sum_pref = pci_region_sum(&r64_pref);
|
|
1113
|
-
u64 align_mem = pci_region_align(&r64_mem);
|
|
1114
|
-
u64 align_pref = pci_region_align(&r64_pref);
|
|
1115
|
-
|
|
1116
|
-
r64_mem.base = le64_to_cpu(romfile_loadint("etc/reserved-memory-end", 0));
|
|
1117
|
-
if (r64_mem.base < 0x100000000LL + RamSizeOver4G)
|
|
1118
|
-
r64_mem.base = 0x100000000LL + RamSizeOver4G;
|
|
1119
|
-
r64_mem.base = ALIGN(r64_mem.base, align_mem);
|
|
1120
|
-
r64_mem.base = ALIGN(r64_mem.base, (1LL<<30)); // 1G hugepage
|
|
1121
|
-
r64_pref.base = r64_mem.base + sum_mem;
|
|
1122
|
-
r64_pref.base = ALIGN(r64_pref.base, align_pref);
|
|
1123
|
-
r64_pref.base = ALIGN(r64_pref.base, (1LL<<30)); // 1G hugepage
|
|
1124
|
-
pcimem64_start = r64_mem.base;
|
|
1125
|
-
pcimem64_end = r64_pref.base + sum_pref;
|
|
1126
|
-
pcimem64_end = ALIGN(pcimem64_end, (1LL<<30)); // 1G hugepage
|
|
1127
|
-
dprintf(1, "PCI: 64: %016llx - %016llx\n", pcimem64_start, pcimem64_end);
|
|
1128
|
-
|
|
1129
|
-
pci_region_map_entries(busses, &r64_mem);
|
|
1130
|
-
pci_region_map_entries(busses, &r64_pref);
|
|
1131
|
-
} else {
|
|
1132
|
-
// no bars mapped high -> drop 64bit window (see dsdt)
|
|
1133
|
-
pcimem64_start = 0;
|
|
1134
|
-
}
|
|
1135
|
-
// Map regions on each device.
|
|
1136
|
-
int bus;
|
|
1137
|
-
for (bus = 0; bus<=MaxPCIBus; bus++) {
|
|
1138
|
-
int type;
|
|
1139
|
-
for (type = 0; type < PCI_REGION_TYPE_COUNT; type++)
|
|
1140
|
-
pci_region_map_entries(busses, &busses[bus].r[type]);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
/****************************************************************
|
|
1146
|
-
* Main setup code
|
|
1147
|
-
****************************************************************/
|
|
1148
|
-
|
|
1149
|
-
void
|
|
1150
|
-
pci_setup(void)
|
|
1151
|
-
{
|
|
1152
|
-
if (!CONFIG_QEMU)
|
|
1153
|
-
return;
|
|
1154
|
-
|
|
1155
|
-
dprintf(3, "pci setup\n");
|
|
1156
|
-
|
|
1157
|
-
dprintf(1, "=== PCI bus & bridge init ===\n");
|
|
1158
|
-
if (pci_probe_host() != 0) {
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
pci_bios_init_bus();
|
|
1162
|
-
|
|
1163
|
-
dprintf(1, "=== PCI device probing ===\n");
|
|
1164
|
-
pci_probe_devices();
|
|
1165
|
-
|
|
1166
|
-
pcimem_start = RamSize;
|
|
1167
|
-
pci_bios_init_platform();
|
|
1168
|
-
|
|
1169
|
-
dprintf(1, "=== PCI new allocation pass #1 ===\n");
|
|
1170
|
-
struct pci_bus *busses = malloc_tmp(sizeof(*busses) * (MaxPCIBus + 1));
|
|
1171
|
-
if (!busses) {
|
|
1172
|
-
warn_noalloc();
|
|
1173
|
-
return;
|
|
1174
|
-
}
|
|
1175
|
-
memset(busses, 0, sizeof(*busses) * (MaxPCIBus + 1));
|
|
1176
|
-
if (pci_bios_check_devices(busses))
|
|
1177
|
-
return;
|
|
1178
|
-
|
|
1179
|
-
dprintf(1, "=== PCI new allocation pass #2 ===\n");
|
|
1180
|
-
pci_bios_map_devices(busses);
|
|
1181
|
-
|
|
1182
|
-
pci_bios_init_devices();
|
|
1183
|
-
|
|
1184
|
-
free(busses);
|
|
1185
|
-
|
|
1186
|
-
pci_enable_default_vga();
|
|
1187
|
-
}
|