summaryrefslogtreecommitdiffstats
path: root/mboxd.c
Commit message (Collapse)AuthorAgeFilesLines
* vpnor: Isolate relevant code in vpnor directoryAndrew Jeffery2018-04-041-1/+1
| | | | | | | | | | | | This is prepatory work for introducing more vpnor-specific behaviours to window handling. We will be introducing more objects to link, in order to hook some of the window command handlers. This change takes the opportunity to revert back to the upstream names for some of the original C files. Change-Id: I6b67ae466a2695054035e65ba752881be9c32d1a Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* misc: Replace license blurb with kernel-style SPDX markersAndrew Jeffery2018-03-241-18/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was roughly achieved by the following shell script: $ git ls-files | grep '\.[ch]p*$' | while read F; do EXT=${F##*.}; cat spdx.$EXT <(sed '/^\/\*$/,/^ \*\/$/d' $F) > ${F}.tmp; mv ${F}.tmp $F; done With the following context: $ cat spdx.c // SPDX-License-Identifier: Apache-2.0 // Copyright (C) 2018 IBM Corp. $ cat spdx.h /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright (C) 2018 IBM Corp. */ $ ls -l spdx.* -rw-r--r-- 1 andrew andrew 71 Feb 27 12:02 spdx.c lrwxrwxrwx 1 andrew andrew 6 Feb 27 12:02 spdx.cpp -> spdx.c -rw-r--r-- 1 andrew andrew 77 Feb 27 12:02 spdx.h lrwxrwxrwx 1 andrew andrew 6 Feb 27 12:02 spdx.hpp -> spdx.h The `sed` invocation catches a lot of function documentation, so the hunks were manually added to avoid removing information that we want to keep. Change-Id: I63e49ca2593aa0db0568c7a63bfdead388642e76 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* vpnor: rename APIsDeepak Kodihalli2017-07-191-6/+2
| | | | | | | | | To maintain consistency, rename vpnor_create_partition_table to init_vpnor and vpnor_destroy_partition_table to destroy_vpnor. Also move a bunch of vpnor specific string copy code from main() to init_vpnor(). Change-Id: Ia1b6598d4d308dd727916dc79be9b3b733f314f2 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* vpnor: create hostboot bootloader partitionDeepak Kodihalli2017-07-191-13/+13
| | | | | | | | | | | | | | | | | | | | | The hostboot bootloader code doesn't use mbox. It has specific requirements: - The PNOR TOC should be at the 'PNOR end - TOC size - page size' offset. It searches for the TOC here, if not found, the search moves down page by page. - The PNOR should be 64M. The page size and erase block should be 4K. The TOC should be 32K. Copy what the bootloader expects to the LPC memory when mboxd starts up. The same needs to be done in the case of an mbox reset (irrespective of where the reset comes from). Skiboot expects that the TOC should be at offset 0, but it uses mbox to read the TOC. So this commit doesn't impact skiboot requirements. Change-Id: I7de556dccfea85f2faa5f401177006a3a562494e Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* vpnor: make PNOR block size configurableDeepak Kodihalli2017-07-191-8/+8
| | | | | | | | The vpnor code would assume a PNOR FFS block size of 4K. Make it possible to supply this value, since it needn't always be 4K. Change-Id: I21463b05f1047e93705ba82d46f746056568dcc5 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* Read/write window property defines FFS partition file location.Ratan Gupta2017-06-291-1/+4
| | | | | | | | | | | | | | | | | | | | | The BMC loads the PNOR partitions in a read-only volume. So after that there are following two cases: Read: Tries to open the file in read only mode from the partition(READONLY/READWRITE/PRESERVED), Partition Table tells the partition type depends on the offset. if file is not there in the mapped partition then tries to open the file from the read only partition. Write: Tries to open the file in write mode from the partition(READWRITE/PRESERVED), if file is not there in the mapped partition then mailbox daemon will copy the requested partition to the read-write volume to make changes to it. Change-Id: Ic0ef882380b56536ac55feae3ec563de95fdd4a6 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Load the partitions into virtual pnorRatan Gupta2017-06-291-0/+1
| | | | | Change-Id: I709c410009fb0047d7e59ddd3a681f25e49341a0 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* msg: handle partition table read requestDeepak Kodihalli2017-06-271-0/+8
| | | | | | | | | | Map host's request to read the flash at offset less than the partition table length as a request to read the pnor partition table. Resolves openbmc/openbmc#1439. Change-Id: I0f5b98f073d983b0d4749b0aba84b37d7f42f884 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
* version: Update to version 2.1.0Suraj Jitindar Singh2017-05-041-2/+2
| | | | | | | | | | | | | | | | Update to package version V2.1.0 to reflect that a backwards compatible API change was made. This API change was the introduction of the timeout to the GET_MBOX_INFO command. This version update also encompasses previous bug fixes. The versioning scheme is now aligned to semver. Use the version from config.h for both mboxd and mboxctl instead of an independant value for the daemon and control programs. Change-Id: I12d7fe8e40697801594b1727054342613923a784 Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
* mboxd: Introduce a new DEBUG log levelSuraj Jitindar Singh2017-05-041-8/+12
| | | | | | | | | | | | | | | | | | | | | | | Currently there is no output on the console unless -v is specified on the command line which enables error output. A second -v will provide info output. We probably want error output irrespective of whether a -v was given on the command line because people generally want to know why their program stopped working. Make error output unconditional. A single -v will give minimal informational output which is a good level to see what the daemon is doing without barfing all over the console. A second -v will enable debug output which will print highly verbose information which will be useful for debugging. Probably don't enable this under normal circumstances. Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Change-Id: I3da25f7e4e9e976c17389fcceb1d85ef98de7e0a
* mboxd: Check that window size is indeed a power of 2Suraj Jitindar Singh2017-04-191-0/+4
| | | | | | | | | | | | | | The window size can be specified on the command line however we restrict this to being a power of 2 due to the internal working of the daemon. Currently we specify that this is the case in the help message but don't explicitly verify this when parsing the command line. Check that if the window size parameter is provided that the value is indeed a power of 2 and error out if this is not the case. Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Change-Id: I0cb36222d53830996380702802373d862010f503
* mboxd: Make window size and number optional command line parametersSuraj Jitindar Singh2017-04-121-36/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The window size and number command line parameters are used to control the number of windows and the size of each of the windows in the window cache which the reserved memory region is divided between. Most people won't care about tuning these or just won't know what they refer to. Additionally in the event we change how the window cache works or allow a non-constant window size then the meaning of these becomes unclear. Daemon implementations may also choose to just not implement a cache so making these required parameters may hurt portability. Make the window size and number command line parameters optional rather than required so that they can be largly ignored while people who really care about tuning them can still do so. The default for now is to have windows of size 1MB and to map the entire reserved memory region. That is: number of windows = size of memory region / size of windows This means that the size of the reserved memory region can be reduced and the daemon will adapt to this. Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Change-Id: I7c7bbef6e5d31d1372ec3a755877cacc6c135cce
* mboxd: Update mboxd to implement protocol V2 and add dbus supportSuraj Jitindar Singh2017-04-111-487/+273
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Version 2 of the mbox protocol contains a few changes such as: - All sizes are in block size - Adds an erase command - Adds new response codes - Adds new BMC events - Open windows commands now take a size directive Update the mailbox daemon to support version 2 of the protocol which includes implementing all of the V2 functionality. Also entirely refactor the mboxd.c code to make it more modular improving readability and maintainability. At the same time improve the functionality by adding: - Multiple windows in the daemon (still only one active window) to cache flash contents - Implement a dbus interface to allow interaction with the daemon - Handle sigterm and sigint and terminate cleanly The previous implementation utilised the entire reserved memory region. Update the daemon so that on the command line the number of windows and the size of each which the reserved memory region will be split into can be specified. The reserved memory region is then divided between the windows, however there can still only be one "active" window at a time. The daemon uses these windows to cache the flash contents meaning the flash doesn't have to be copied when the host requests access assuming the daemon already has a copy. A dbus interface is added so that commands can be sent to the daemon to control it's operation from the bmc. These include suspending and resuming the daemon to synchronise flash access, telling the daemon to point the lpc mapping back to flash and telling the daemon when the flash has been modified out from under it. Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Change-Id: I10be01a395c2bec437cf2c825fdd144580b60dbc
* mboxd: Fix MBOX_C_GET_FLASH_INFO to return size specified on command lineSuraj Jitindar Singh2017-03-091-1/+1
| | | | | | | | | | | | The MBOX_C_GET_FLASH_INFO command is supposed to return the size of the file which was specified by the "flash" option on the command line. However currently the actual size of the flash chip its self is being reported. Fix the MBOX_C_GET_FLASH_INFO command to correctly return the size of the file rather than the whole flash size. Change-Id: Ic7425dde8eca187a85e9bcec4084d5abc501c8da Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
* mboxd: Workaround buggy kernel flash driverCyril Bur2017-01-251-5/+16
| | | | | | | | | | | | | | | Currently when mboxd starts (and on every SIGHUP) it reads the entire flash into RAM (typically 32 or 64M). This large read causes the kernel to become unresponsive for an extended period of time (in the order of 10s of seconds). This period of unresponsiveness can cause misbehaviour by the BMC, in particular it often causes SSH sessions to drop. This patch is a temporary workaround until the kernel driver has been fixed, at that point this patch should be reverted! Patch originally from Michael Neuling <mikey@neuling.org>. Change-Id: Ibd848a4074fc7bdcab194d669806589f9d274c93 Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
* mboxd: Zero ioctl() map structCyril Bur2017-01-251-4/+5
| | | | | Change-Id: I5528432af3e211bbac7d86cdf7e57beb0d1a6c0b Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
* Fix MBOX_C_RESET_STATE command crashMichael Neuling2017-01-181-17/+9
| | | | | | | | | | | | | | | | Currently MBOX_C_RESET_STATE tries to access context->fds[LPC_CTRL_FD].fd but it's set to a negative value to avoid being part of the poll loop. This causes MBOX_C_RESET_STATE command crashes with: [MBOXD 1479755597.524480127] Couldn't MAP the host LPC bus to the platform flash [MBOXD 1479755597.524710309] Couldn't point the LPC BUS back to actual flash [MBOXD 1479755597.525068895] Error handling MBOX event: Bad file descriptor This patches removes the negative FDs and setups up a polls FD number for the number of FDs to poll. Signed-off-by: Michael Neuling <mikey@neuling.org>
* mboxd: Add command-line option to specify platform flash sizeCyril Bur2017-01-181-8/+40
|
* Enable SIGHUP to reset point to flash are reread flash.Michael Neuling2017-01-171-13/+63
|
* mboxd: Use MAP ioctl() to reset to flashCyril Bur2017-01-171-38/+20
|
* mboxd: Whitespace cleanupsAndrew Jeffery2017-01-171-1/+1
| | | | Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* mboxd: Fixup unused-result compilation warningAndrew Jeffery2017-01-171-2/+8
| | | | | | | | | | cc -Wall -O2 -g -I. -DPREFIX="\"MBOXD\"" mboxd.c common.o -o mboxd mboxd.c: In function ‘dispatch_mbox’: mboxd.c:170:5: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result] read(-context->fds[MTD_FD].fd, context->lpc_mem, context->size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* mboxd: Test the single write functionalityCyril Bur2017-01-171-0/+26
|
* mboxd: Stripped down super simple daemonCyril Bur2017-01-161-0/+508
This daemon may prove useful for debugging and for adding features. Production daemons will likely need to be better designed
OpenPOWER on IntegriCloud