aboutsummaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)AuthorFilesLines
2024-09-13esp: correctly terminate successful SCSI commandsHEADlatestmasterMark Cave-Ayland1-5/+14
An upcoming series for QEMU's ESP emulation will check that ESP commands are only issued according to their valid states as listed in the datasheet, and otherwise generate an illegal command interrupt. Currently if a SCSI command is expected to return no data or transfers data successfully, the ASC is not returned to its disconnected state. This means that any subsequent ESP initiator commands should be rejected until the SCSI bus transaction is terminated. Update the ESP driver so that if a SCSI command is successful then the ICCS and MSGACC commands are issued by the host to complete the SCSI transaction. This ensures that the ASC is returned to the disconnected state which allows the ESP to accept subsequent SCSI commands without generating an illegal command interrupt. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2024-09-13esp: use ESP rather than DMA interrupt to detect end of transferMark Cave-Ayland1-8/+8
Rather than rely on the DMA interrupt to determine that an ESP interrupt has occurred, poll the ESP interrupt register directly. This enables us to poll until one of the specified interrupts occurs. Since an ESP interrupt can still be in a pending state before issuing an ESP command, read the ESP interrupt register beforehand to clear any pending interrupts. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2024-09-13esp: clear FIFO before issuing ESP commandMark Cave-Ayland1-0/+2
This ensures that any partially transferred data is removed from the FIFO before issuing the next ESP command. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2024-09-06cuda: fix len calculation in cuda_adb_reqAmadeusz Sławiński via OpenBIOS1-1/+1
When advancing buffer by 1, len should be shorthened by appropriate amount, instead of setting it to -1. Found with cppcheck. Signed-off-by: Amadeusz Sławiński <amade@asmblr.net> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2024-04-22drivers/usb.c: rework descriptor read logic in get_descriptor()Mark Cave-Ayland1-9/+8
When compiling with gcc 12 drivers/usb.c generates the following error: /root/drivers/usb.c: In function 'get_descriptor': /root/drivers/usb.c:200:23: error: array subscript 'device_descriptor_t[0]' is partly outside array bounds of 'u8[8]' {aka 'unsigned char[8]'} [-Werror=array-bounds] 200 | if (dd->bMaxPacketSize0 != 0) | ^~ /root/drivers/usb.c:181:12: note: object 'buf' of size 8 181 | u8 buf[8]; | ^~~ cc1: all warnings being treated as errors make[1]: *** [rules.mak:229: target/drivers/usb.o] Error 1 make[1]: Leaving directory '/root/obj-ppc' The compiler is complaining that a device_descriptor_t pointer cast to the 8 byte buffer means that a pointer dereference to some members of the device_descriptor_t could go beyond the end of the 8 byte buffer. Whilst this sounds as if it should be allowed, some searching suggests that the behaviour of such a cast is undefined. Rework get_descriptor() so that an entire device_descriptor_t is used to store the first 8 bytes of the incoming descriptor, and update the buf references to use the equivalent device_descriptor_t fields instead. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2024-04-16Label fallthroughs in switch()esAmadeusz Sławiński1-1/+1
There is few places where code wants to fallthrough, label them so it is known that it is expected. Detected with -Wimplicit-fallthrough Signed-off-by: Amadeusz Sławiński <amade@asmblr.net> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2024-04-16adb_kbd.c: Fix function key definitionsAmadeusz Sławiński1-1/+1
Fix typo, where last definition should have been F16 instead of F15. Found with -Woverride-init Signed-off-by: Amadeusz Sławiński <amade@asmblr.net> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2023-01-26Use parse-nhexBALATON Zoltan2-10/+2
Instead of reimplementing it several times use parse-nhex to decode two hex numbers, Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-27cuda: fix get-time wordGlenn Washburn1-1/+1
An extra byte is written after the CUDA_GET_TIME command causing the command to return an incorrect time. Running QEMU with CUDA debug messages on yields these messages: 1177318@1642469573.070752:cuda_packet_receive length 3 1177318@1642469573.070768:cuda_packet_receive_data [0] 0x01 1177318@1642469573.070771:cuda_packet_receive_data [1] 0x03 1177318@1642469573.070773:cuda_packet_receive_data [2] 0xfb 1177318@1642469573.070776:cuda_receive_packet_cmd handling command GET_TIME CUDA: GET_TIME: wrong parameters 2 Fix the outgoing command length to remove the extra byte. Signed-off-by: Glenn Washburn <development@efficientek.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-14drivers: Spell QEMU all capsPhilippe Mathieu-Daudé1-1/+1
Replace Qemu -> QEMU. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2022-01-14drivers/usb: Fix building with gcc 10.xBALATON Zoltan1-9/+7
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-10-30cuda: fix reset-all and power-off wordsMark Cave-Ayland1-2/+2
There is a long-standing bug in the CUDA implementation of the reset-all and power-off words whereby an extra byte is written after the CUDA_RESET_SYSTEM and CUDA_POWERDOWN commands. This extra byte used to be ignored in QEMU until commits 017da0b568 ("cuda: port POWERDOWN command to new framework") and 54e894442e ("cuda: port RESET_SYSTEM command to new framework") added a check which rejects the command if the command length is incorrect. Fix the outgoing command length to remove the extra byte which allows the reset-all and power-off words to work in QEMU once again. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Hervé Poussineau <hpoussin@reactos.org> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/624
2021-09-02escc: send software reset command before configuring the portMark Cave-Ayland1-0/+6
According to the ESCC datasheet all register values are undetermined until an explicit reset command is sent. This is required to fix an issue with QEMU's ESCC device to ensure that the registers are set to default values if the default power-on values are changed. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-09-02escc: add port index to uart_init_line()Mark Cave-Ayland1-3/+3
This will be needed to allow uart_init_line() to reset the correct port. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-15pci: Rename pci_xbox_blacklisted() as pci_xbox_ignore_device()Philippe Mathieu-Daudé1-5/+2
In order to use inclusive terminology, rename pci_xbox_blacklisted() as pci_xbox_ignore_device(), and remove an obvious comment. Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-1540p: simplify IRQ swizzlingPhilippe Mathieu-Daudé1-20/+7
LSI SCSI on PReP is the unique particular case where we use fixed IRQ routing. All other cases use regular IRQ swizzling. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-1540p: use is_apple() macroPhilippe Mathieu-Daudé1-1/+1
Simplify using the is_apple() macro. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2021-02-1540p: Allow Raven controller to handle all IRQsPhilippe Mathieu-Daudé1-1/+1
In commit ce7fa4d29b we adapted to match QEMU (invalid) code. Now than QEMU has been fixed and handle the 4 IRQs, update the OF device tree again. Reported-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-05-16virtio: limit ring size to a maximum of 128 descriptor entriesMark Cave-Ayland2-3/+9
QEMU commit c9b7d9ec21 "virtio: increase virtqueue size for virtio-scsi and virtio-blk" increased the number of queue descriptors from 128 to 256 which caused OpenBIOS to fail when booting from a virtio-blk device under qemu-system-ppc due to a memory overflow. Update the virtio-blk driver so that it uses a maximum of 128 descriptor entries (the previous value) to fix the issue, and also ensure that any further increases in virtqueue size will not cause the same failure. Note that this commit also fixes the vring_area size calculation which was incorrectly based upon the number of virtqueues, and not the number of descriptor entries. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2020-05-16pci: Enable bus-master on virtio_blkBrandon Bergren1-0/+3
In qemu 9d7bd0826f2d19f88631ad7078662668148f7b5f, the behavior of vring processing was changed to not run whenever bus-mastering is disabled. Since we were never enabling it in the first place, OpenBIOS was no longer able to access virtio disks on qemu. Fix this by enabling bus-mastering before initializing. Signed-off-by: Brandon Bergren <git@bdragon.rtk0.net> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-10-22ide: locate drives by iterating over the device tree during ob_ide_quiesce()Mark Cave-Ayland1-22/+8
It is now possible to locate IDE drives by searching the device tree for "block" type devices containing a C drive instance variable. Rewrite ob_ide_quiesce() to locate and quiesce IDE drives using this method which finally enables us to remove the global IDE channels list and its remaining ide_add_channel() function. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-10-22ide: use instance values to hold C drive and channel structuresMark Cave-Ayland2-27/+15
Rather than iterate over the global IDE channels list, use instance variables to hold the relevant pointers. This allows us to remove ide_seek_channel() since it is no longer necessary for each IDE device to iterate over the global list in order to locate the drive/channel information. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-10-17escc: explicitly mark variable containing incoming keyboard character as ↵Mark Cave-Ayland1-1/+1
volatile Otherwise the compiler may not understand that a read from the assigned buffer is comming from memory-mapped IO space and fail to update accordingly. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18virtio: use instance value to initialise C instance parameterMark Cave-Ayland1-35/+11
This simplifies the open word by avoiding having to locate and read the value of the _vdev property. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18lsi: use instance value to hold sd_private_t pointerMark Cave-Ayland1-17/+25
It is also possible to remove the global_lsi variable by adding a pointer to the parent lsi_private_t instance within sd_private_t. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pc_kbd: use instance value to initialise C instance parameterMark Cave-Ayland1-9/+7
This simplifies the open word by avoiding having to locate and read the value of the address property. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pc_serial: remove separate init wordMark Cave-Ayland1-8/+5
Instead use an instance value and initialise the C instance parameter within the open word. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pci: call set-args before configuring PCI device nodesMark Cave-Ayland1-0/+21
This is to ensure that the my-space and my-address words are set correctly for any PCI devices that wish to execute FCode. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pci: remove explicit setting of my-self from PCI devicesMark Cave-Ayland2-9/+0
Since the correct current instance is now being set during probe, there is no need to explicitly set it whilst creating the device. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pci: remove explicit find-device from PCI devicesMark Cave-Ayland13-51/+0
Since the correct active package is now being set during probe, there is no need to explicitly find the parent node before creating the device. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18SPARC64: set active package and current instance to root device node before ↵Mark Cave-Ayland1-3/+0
probe Now that all PCI devices have been converted to new-device...finish-device we can set both the active package and current instance to the root device node before probe, giving all child devices a correct active package and instance chain during creation. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18ppc: move New World uninorth and nvram device node creation to the root deviceMark Cave-Ayland3-6/+1
Whilst the NVRAM device node exists under the mac-io device node for Old World Macs, both itself and the Uninorth device node exist under the root device node on New World Macs. Move creation of both device nodes to arch_of_init() for New World machines to enable the active package and current instance to be set correctly during device tree construction. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18nvram: ensure that NVRAM configuration is separate from NVRAM node creationMark Cave-Ayland1-0/+1
As part of this separation we can also move "update-nvram" directly to the NVRAM node bindings. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pci: remove ob_pci_initialize() and ob_pci_empty_nodeMark Cave-Ayland1-15/+0
The ob_pci_initialize() function can be removed as it is empty, whilst ob_pci_empty_node is no longer required since the existing fallback code will always apply the ob_pci_simple_node bindings if no callback is configured. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pci: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-53/+43
Moving the setup of PCI devices to within a new-device...finish-device sequence as part of the conversion further enables us to move the PCI host bridge configuration logic from ob_pci_init() to ob_configure_pci_device() where it belongs. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18virtio: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-4/+2
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18lsi: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-2/+5
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18lsi: don't change active package when setting device aliasMark Cave-Ayland1-6/+5
When generating the DT based upon the active package and current instance, we cannot change either when setting the alias. Instead look up the phandle and then set the properties directly. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18nvram: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-4/+4
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18usbhid: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-6/+14
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pmu: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-48/+107
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18macio: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-50/+61
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18cuda: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-61/+100
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18escc: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-42/+72
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18adb: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland3-40/+82
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18ide: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-49/+80
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18floppy: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-31/+40
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pc_serial: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-8/+14
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18pc_kbd: convert to use BIND_NODE_METHODS() macroMark Cave-Ayland1-11/+14
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
2019-08-18all: gcc 9 build fixesMark Cave-Ayland3-5/+5
Fix up warnings generated by building with -Werror under gcc 9. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>