aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2016-02-08virtio-net: fix gcc warnings (-Wextra)Nikunj A Dadhania4-6/+6
Change rx_size type which originally should have been uint32_t. This also requires a change in the function prototype. Also change the return type of virtio_9p_load() to silence another gcc warning Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-02-08virtio-blk: fix gcc warnings (-Wextra)Nikunj A Dadhania2-2/+2
Change the prototype of virtioblk_read as blocknum wont be negative Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2016-01-11Fix format strings in usb-ohci.cThomas Huth1-6/+6
When compiling with OHCI_DEBUG enabled, gcc complains about a lot of bad format strings. So let's use more appropriate format modifiers to fix these warnings. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-23libc: Add srand() callThomas Huth2-0/+6
Needed for seeding the state of the pseudo-random number generator. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-23libc: Fix the rand() function to return non-zero valuesThomas Huth1-2/+2
The rand() function in SLOF's libc has a bug which caused the function to always return zero: The _rand value was shifted left by 16, and then ANDed with 0x7fff. Obviously, the shift operation should be ">>" instead of "<<". And while we're at it, also increase the constant for the multiplaction in there so that more upper bits are affected. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-09usb: print unhandled descriptor in debug modeNikunj A Dadhania1-1/+1
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-02Improve stack usage with libnvram get_partition functionThomas Huth3-16/+14
The Forth-to-C wrapper for get-named-nvram-partition also uses the STRING_INIT macro. This causes heavy stack usage in the engine() function due to the static array in that macro. So let's rework the wrapper to do the string convertion in a separate function instead. Now that all users of the STRING_INIT and STRING_FROM_STACK macros are gone, the macros can be removed, too. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-02Improve stack usage in libnvram environment variable codeThomas Huth3-40/+48
The Forth-to-C wrapper code in libnvram.code uses a temporary buffer of 255 bytes via the STRING_INIT macro for each Forth string that has to be converted to a C string. However, using such big arrays in the wrapper code is a bad idea: Each of the buffers is put into the stack frame of the engine() function (from paflof.c)! That means the 7 strings from libnvram.code increase the stack usage of engine() by 7 * 255 = 1785 bytes! This can cause stack overflows since engine() can be called recursively, e.g. via the forth_eval() macro. To fix this issue in the functions from envvar.c, we can simply pass the Forth strings directly to the functions by adding the string length as additional function parameter, since the functions in envvar.c don't really depend on NUL-terminated strings. And while we're at it (i.e. we touch the function prototypes here anyway), also rename the functions to have a proper "nvram_" prefix, so we clearly mark them as part of libnvram instead of cluttering the global name space with rather trivial function names. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-02libc: Port vsnprintf back from skibootAlexey Kardashevskiy1-62/+118
Since initial port from slof to skiboot, vsnprintf() has improved in skiboot so let's port the improved version back. Suggested-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-01Move the code for rfill into a separate functionThomas Huth2-1/+39
The code from the FAST_RFILL macro uses a local array as a temporary buffer - which gets allocated in the stack frame of the engine() function. Since engine() can be called recursively, this can cause stack overflows. So let's move the rfill code into a separate function to avoid these problems. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-01Rework wrapper for new_nvram_partition() and fix possible bug in thereThomas Huth3-12/+22
The wrapper for new_nvram_partition() is using a 12 bytes buffer to create a zero-terminated string. However, if the string has exactly 12 characters, the final NUL-terminator is missing. new_nvram_partition() then calls create_nvram_partition() internally which depends on proper NUL-terminated strings. So fix this by making sure that the copied string is always NUL-terminated - and while we're at it, also move the copy code out of libnvram.code to save some precious bytes in the stack space of the engine() function. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-12-01Stack optimization in libusb: split up setup_new_device()Thomas Huth7-40/+52
When scanning hubs, the code in libusb can be called recursively, for example usb_hub_init() calls setup_new_device(), which then calls slof_usb_handle() to execute Forth code for the next device. If that next device is a hub, we end up recursively in usb_hub_init() again. Since stack space is limited in SLOF, we can optimize here a little bit by splitting up the setup_new_device() function into the part that retrieves the descriptors (which takes most of the stack space in this code path since the descriptors are placed on the stack), and the part that populates the the device tree node of the new device (which is responsible for the recursion). Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-22Fix special keys on USBDinar Valeev1-9/+7
This patch fixing HOME, INS, END and DEL keys in Grub, when USB keyboard is used. Those keys are useful in faster grub interaction in automated tests. Signed-off-by: Dinar Valeev <dvaleev@suse.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-22Fix function keys on USBDinar Valeev1-16/+12
This is fixing F1-F12 keys in grub2. Sequence was grabbed by running cat in xterm and pressing relative function key. Signed-off-by: Dinar Valeev <dvaleev@suse.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: add keyboard supportNikunj A Dadhania2-1/+120
Add support for xhci interrupt pipes needed for keyboard handling Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: ready the link trb earlyNikunj A Dadhania1-7/+6
The keyboard events being async, need to prepare the link when last but one trb is queued. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: scan usb high speed portsNikunj A Dadhania1-9/+30
Current code scanned only the super speed ports. Add support for scanning high speed ports as well. Also re-org code to reduce duplication of code. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: bulk improve event handling loopNikunj A Dadhania1-9/+32
Since the controller was being used by single user, event poll loop works without verifying what event returned. Now with usb-keyboard addition where we will get keyboard events, this would not work. Transfer bulk would only look for response from the trb queued and ignore rest of the events. Moreover, while bulk transfer is going on, there are no keyboard events in booting use case. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: return on allocation failureNikunj A Dadhania1-1/+2
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: add delay in shutdown pathNikunj A Dadhania1-0/+12
QEMU implementation of XHCI doesn't implement halt properly. There might be ongoing activities and active DMAs, introduce 50ms delay during shutdown path. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-xhci: event trbs does not need link trbNikunj A Dadhania1-4/+6
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-10-06usb-hid: refactor usb key readingNikunj A Dadhania1-7/+4
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-07-20usb-hid: Caps is not always shiftDinar Valeev1-3/+27
Caps behaves like shift only for latin characters. In case we're typing - for example with caps enabled, SLOF picks _ char from shifted table. Treat caps as shift only for letters. Signed-off-by: Dinar Valeev <dvaleev@suse.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-03-23Fix "key?" Forth word when using USB keyboardsThomas Huth1-9/+21
The "key?" Forth word did not work when being used for polling keyboard events from USB keyboards since the usb_key_available() function never triggered any USB transfers. Fix it by also refactoring usb_read_keyb() a little bit so that both functions now use the same code for checking for new keyboard events. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-03-23Include make.rules in the library MakefilesThomas Huth7-0/+14
Make sure to include make.rules from the Makefiles in the common lib folder to get some more sane console output during the build process. Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-03-13virtio: Fix vring allocationAlexey Kardashevskiy1-2/+4
The value returned by virtio_vring_size() is used to allocate memory for vring. The used descriptor list (array of vring_used_elem) is counted by the header - vring_used struct - is not. This fixes virtio_vring_size() to return the correct size. At the moment rings are quite small (256) and allocated with 4096 alignment, this is why we have not been having issues with this so far. Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com> Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * remove magic numbers
2014-10-29usb-xhci: support xhci extended capabilitiesNikunj A Dadhania2-6/+41
commit 706c69e4 "xhci: fix port assignment" partially fixed the usb port numbering. Adding parsing of xhci extended capabilities, we can parse the overlapped ports accordingly and have proper port numbering. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-08-27Add private HCALL to inform updated RTAS base and entryNikunj A. Dadhania3-1/+10
This patch adds a private HCALL to inform qemu the updated rtas-base and rtas-entry address when OS invokes the call "instantiate-rtas". This is required as qemu allocates the error reporting structure in RTAS space upon a machine check exception and hence needs to know the updated RTAS. Enhancements to qemu to handle the private HCALL, prepare error log and invoke machine check notification routine are in a separate patch. Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Aravinda Prasad <aravinda@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-07-17xhci: fix port assignmentNikunj A Dadhania1-1/+1
Port assignment logic was generating negative port number Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-25xhci: fix controller stopNikunj A Dadhania1-1/+1
A bit operation bug left the controller in the running state causing PCI EEH in the host when using pci-passthru for USB3 device. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-25virtio-blk: support variable block sizeNikunj A Dadhania6-20/+49
Current code only works with 512 bytes read. Moreover, Qemu ignores the guest set features request. In the set features request SLOF indicates to qemu that it is not support VIRTIO_BLK_F_BLK_SIZE feature. Code in qemu suggests that virtio-blk is not implementing set_guest_feature. Tested-by: Bharata B Rao <bharata@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-04-08e1000: fix usage of multiple nicsNikunj A Dadhania3-4/+6
When using multiple e1000 network interface netboot would fail if we try to boot from the first interface. During first e1000 device initialization, m_e1k.m_baseaddr_u64 (static variable) is set to read/write pci registers. Later the second device does process. When first e1000 driver tries netboot, it has an assumption that m_e1k.m_baseaddr_u64 is correct, which is not the case. Ensure reinitialization for m_e1k.m_baseaddr_u64 when open interface of device is called. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
2014-04-04Isolate sc 1 detection logicAlexander Graf1-28/+28
Under weird circumstances we ended up with unsynchronized data and text section references between the stage1 and paflof binaries. This patch moves the initial sc 1 detection logic to work without any persistent state, making it properly reentrant regardless of the place we end up hitting the code at. This fixes broken sc 1 detection for me on PR KVM. Signed-off-by: Alexander Graf <agraf@suse.de> [aik: added r0 to clobber list and $(FLAG) to AS1FLAGS as suggested by agraf, tested on pHyp] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2014-03-26usb-core: adjust port numbers in set_addressNikunj A Dadhania1-1/+8
There is a mismatch between the port number between qemu and slof. Was unearthed while using bootindex. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-03-18ELF: Enter LE binary in LE modeNikunj A Dadhania2-1/+12
Trampoline code in the LE binary were helping fix this. This patch now takes care of switching the mode to LE for LE elf binaries. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-03-18ELF loading should fail for virt != physNikunj A Dadhania3-9/+16
Prevent loading of elf files which does not have virtual address same as physical address. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-02-04virtio-9p: disable unused structureNikunj A Dadhania1-1/+2
In file included from ./board.code:140:0, from /home/nikunj/work/power/code/slof/SLOF/slof/paflof.c:106: /home/nikunj/work/power/code/slof/SLOF/slof/paflof.c: In function ‘engine’: /home/nikunj/work/power/code/slof/SLOF/lib/libvirtio/virtio-9p.h:23:3: warning: typedef ‘virtio_9p_config_t’ locally defined but not used [-Wunused-local-typedefs] } virtio_9p_config_t; Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2014-02-04Add support for 64bit LE ABI v1 and v2 supportNikunj A Dadhania2-2/+18
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> -- v2: With the parameters changed for go-64, kernel loading from commandline broke v3: (client-exec) calls start-elf64 directly, fix args
2014-01-20[oex]hci_exit: Check before freeing/unmapping memoryNikunj A Dadhania3-16/+38
While doing cleanup of the allocated memory, make sure addresses being unmapped/free were really allocated. During error conditions, some address would not have been. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-12-17Work around missing sc 1 traps on pHypAlexander Graf5-1/+174
When running a pseries guest in PR KVM on top of pHyp, sc 1 instructions are handled directly by pHyp, so we don't get to see them. That means we need to get inventive. Invent a new instruction that behaves like sc 1, but really is a reserved instruction that traps. This instruction can be used by KVM to emulate sc 1 behavior. This patch adds the SLOF support for it. With this, SLOF detects whether it's running on such a broken setup and if so patches itself to execute the fake sc 1 instruction instead of the real one. Furthermore, we also hook into "quiesce" which Linux calls when it boots. This gives us the chance to also patch Linux when it boots up, so it uses the fake sc 1 too. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-12-16usb-xhci: memory freeing and using returns as bool uniformlyNikunj A Dadhania2-26/+41
* Fix freeing of memory in error path * Boolean and int were used interchangebly at various points, consolidate it to use boolean Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-12-16Output banner and initial display output in VNC windowNikunj A Dadhania4-2/+17
Initial display output does not show up in the VGA/VNC window. Create replay buffer to store the initial output and when vga/vnc console starts, dump the buffer there. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-12-06Add support for loading little endian ELF binaries.Anton Blanchard3-6/+95
We byte swap the entire header in place in elf_check_file. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-18virtio: timeout after 5secNikunj A Dadhania3-12/+20
Remove adhoc timer and put 5sec timeout. On a busy host, code hits this. Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-17usb-ohci: fix warningsNikunj A Dadhania1-3/+2
usb-ohci.c: In function ‘ohci_process_done_head’: usb-ohci.c:458:4: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘struct ohci_td *’ [-Wformat] usb-ohci.c:417:20: warning: variable ‘start_frame’ set but not used [-Wunused-but-set-variable] Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-17e1000: fix SLOF_dma_map_out argumentsAvik Sil1-1/+1
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
2013-11-17Increase virtio-net receive queue sizeAvik Sil1-1/+1
Since SLOF is poll based, in a high network traffic zone desired packet might be missed during receiving. Hence increase the receive queue size. Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
2013-11-17Increase veth receive queue sizeAvik Sil1-1/+1
Since SLOF is poll based, in a high network traffic zone desired packet might be missed during receiving. Hence increase the receive queue size. Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com>
2013-11-16Fix dprintf macros at various pointsNikunj A Dadhania9-10/+10
Signed-off-by: Avik Sil <aviksil@linux.vnet.ibm.com> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
2013-11-15usb-ohci: rewrite done_head processing codeNikunj A Dadhania1-55/+59
The routine had got complicated and source of few bugs while using in pci-passthru and js2x Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>