summaryrefslogtreecommitdiffstats
path: root/hw/sd.c
Commit message (Collapse)AuthorAgeFilesLines
* sd: Remember to reset .expecting_acmd on reset.Andrzej Zaborowski2011-12-211-0/+1
| | | | Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Clear status bits when read via response r6Peter Maydell2011-12-211-0/+1
| | | | | | | | Response format r6 includes a subset of the status bits; clear the clear-on-read bits which are read by an r6 response. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Correct handling of APP_CMD status bitPeter Maydell2011-12-211-7/+17
| | | | | | | | | | | | | | Fix some bugs in our implementation of the APP_CMD status bit: * the response to an ACMD should have APP_CMD set, not cleared * if an illegal ACMD is sent then the next command should be handled as a normal command This requires that we split "card is expecting an ACMD" from the state of the APP_CMD status bit (the latter indicates both "expecting ACMD" and "that was an ACMD"). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Correct handling of type B SD status bitsPeter Maydell2011-12-211-19/+25
| | | | | | | | | | | Correct how we handle the type B ("cleared on valid command") status bits. In particular, the CURRENT_STATE bits in a response should be the state of the card when it received that command, not the state when it received the preceding command. (This is one of the issues noted in LP:597641.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Set ILLEGAL_COMMAND for ACMDs in invalid statePeter Maydell2011-12-211-1/+1
| | | | | | | | App commands in an invalid state should set ILLEGAL_COMMAND, not merely return a zero response. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Handle CRC and locked-card errors in normal code pathPeter Maydell2011-12-211-2/+5
| | | | | | | | | | Handle returning CRC and locked-card errors in the same code path we use for other responses. This makes no difference in behaviour but means that these error responses will be printed by the debug logging code. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Handle illegal commands in sd_do_commandPeter Maydell2011-12-211-14/+11
| | | | | | | | | | | | Add an extra sd_illegal value to the sd_rsp_type_t enum so that sd_app_command() and sd_normal_command() can tell sd_do_command() that the command was illegal. This is needed so we can do things like reset certain status bits only on receipt of a valid command. For the moment, just use it to pull out the setting of the ILLEGAL_COMMAND status bit into sd_do_command(). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: When setting ADDRESS_ERROR bit, don't clear everything elsePeter Maydell2011-12-211-2/+2
| | | | | | | | Fix a typo that meant that ADDRESS_ERRORs setting or clearing write protection would clear every other bit in the status register. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: On CRC error, set CRC error status bit rather than clearing itPeter Maydell2011-12-211-1/+1
| | | | | | | | | If we fail to validate the CRC for an SD command we should be setting COM_CRC_ERROR, not clearing it. (This bug actually has no effect currently because sd_req_crc_validate() always returns success.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Add comment regarding CARD_STATUS_* definesPeter Maydell2011-12-211-0/+5
| | | | | | | | Add a clarifying comment about what the CARD_STATUS_[ABC] macros are defining. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* hw/sd.c: Fix the set of commands which are failed when card is lockedPeter Maydell2011-12-211-7/+22
| | | | | | | | | | | | | | | Fix bugs in the code determining whether to accept a command when the SD card is locked. Most notably, we had the condition completely reversed, so we would accept all the commands we should refuse and refuse all the commands we should accept. Correct this by refactoring the enormous if () clause into a separate function. We had also missed ACMD42 off the list of commands which are accepted in locked state: add it. This is one of the two problems reported in LP:597641. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* block: New change_media_cb() parameter loadMarkus Armbruster2011-09-121-1/+1
| | | | | | | To let device models distinguish between eject and load. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Declare qemu_blockalign() in block.h, not block_int.hMarkus Armbruster2011-09-061-1/+0
| | | | | | | | Device models should be able to use it without an unclean include of block_int.h. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Split change_cb() into change_media_cb(), resize_cb()Markus Armbruster2011-09-061-6/+2
| | | | | | | Multiplexing callbacks complicates matters needlessly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Generalize change_cb() to BlockDevOpsMarkus Armbruster2011-09-061-1/+5
| | | | | | | So we can more easily add device model callbacks. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Attach non-qdev devices as wellMarkus Armbruster2011-09-061-0/+1
| | | | | | | | | | | | | For now, this just protects against programming errors like having the same drive back multiple non-qdev devices, or untimely bdrv_delete(). Later commits will add other interesting uses. While there, rename BlockDriverState member peer to dev, bdrv_attach() to bdrv_attach_dev(), bdrv_detach() to bdrv_detach_dev(), and bdrv_get_attached() to bdrv_get_attached_dev(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-3/+3
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* sd: do not add one sector to the disk sizeVincent Palatin2011-07-301-3/+1
| | | | | | | | | This leads to random off-by-one error. When the size of the SD is exactly 1GB, the emulation was returning a wrong SDHC CSD descriptor. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* Fix last sector write on sd cardDr. David Alan Gilbert2011-07-291-8/+11
| | | | | | | | | | | When writing the last sector of an SD card using WRITE_MULTIPLE_BLOCK QEmu throws an error saying that we've run off the end, and leaves itself in the wrong state. Tested on ARM Vexpress model. Signed-off-by: Dr. David Alan Gilbert <david.gilbert@linaro.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* hw/sd.c: Don't complain about SDIO commands CMD52/CMD53Peter Maydell2011-05-221-0/+11
| | | | | | | | | | The SDIO specification introduces new commands 52 and 53. Handle as illegal command but do not complain on stderr, as SDIO-aware OSes (including Linux) may legitimately use these in their probing for presence of an SDIO card. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* hw/sd.c: fix sd_set_cb() crash when bdrv == NULLAurelien Jarno2011-03-061-2/+2
| | | | | | | | | | sd_set_cb() calls bdrv_is_read_only() and bdrv_is_inserted() even if no block driver is associated with the card reader. This patch fixes the issues by not setting the irq in this case, this fixes ARM versatile crash. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* hw/sd.c: Add missing state change for SD_STATUS, SEND_NUM_WR_BLOCKSPeter Maydell2011-02-241-0/+2
| | | | | | | | | | | | The SD_STATUS and SEND_NUM_WR_BLOCKS commands are supposed to cause the card to send data back to the host. However sd.c was missing the state change to sd_sendingdata_state for these commands, with the effect that the Linux driver would either hang indefinitely waiting for nonexistent data (pl181) or read zeroes and provoke a qemu warning message (omap). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* block: tell drivers about an image resizeChristoph Hellwig2011-01-311-1/+6
| | | | | | | | Extend the change_cb callback with a reason argument, and use it to tell drivers about size changes. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Fix compilation error (missing include statement)Stefan Weil2010-09-221-0/+1
| | | | | | | | | | | | ./hw/sd.c: In function ‘sd_init’: ./hw/sd.c:443: error: implicit declaration of function ‘qemu_blockalign’ ./hw/sd.c:443: error: nested extern declaration of ‘qemu_blockalign’ ./hw/sd.c:443: error: assignment makes pointer from integer without a cast Cc: Christoph Hellwig <hch@lst.de> Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* use qemu_blockalign consistentlyChristoph Hellwig2010-09-211-1/+1
| | | | | | | | | Use qemu_blockalign for all allocations in the block layer. This allows increasing the required alignment, which is need to support O_DIRECT on devices with large block sizes. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* arm: remove dead assignments, spotted by clang analyzerBlue Swirl2010-04-251-6/+2
| | | | | | Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* handle SD CMD5 without error messagesJuha Riihimäki2009-12-181-0/+4
| | | | | | | From: Juha Riihimäki <juha.riihimaki@nokia.com> Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com> Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* hw/sd: Support SDHC size cardsAndrzej Zaborowski2009-11-031-60/+84
| | | | | | | | This patch adds SHDC support (-sd sd.img, where sd.img is larger than 1GB) to qemu. Signed-off-by: Jason S. McMullan <jason.mcmullan@gmail.com> Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
* Revert "Get rid of _t suffix"Anthony Liguori2009-10-011-6/+6
| | | | | | | | | | | | In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Get rid of _t suffixmalc2009-10-011-6/+6
| | | | | | | Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
* Replace gcc variadic macro extension with C99 versionBlue Swirl2009-05-131-3/+3
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Follow coding conventionsPaul Brook2009-05-101-4/+4
| | | | | | Remove explicit struct qualifiers and rename structure types. Signed-off-by: Paul Brook <paul@codesourcery.com>
* Handle NULL bdrv.Paul Brook2009-05-031-4/+10
| | | | Signed-off-by: Paul Brook <paul@codesourcery.com>
* Delete some unused macros detected with -Wp,-Wunused-macros useblueswir12009-03-161-2/+0
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6856 c046a42c-6fe2-441c-8c8c-71466251a162
* do not pretend to support low voltage operationaurel322009-03-071-1/+1
| | | | | | | | | | | Eliminate "mmc0: SD card claims to support the incompletely defined 'low voltage range'. This will be ignored." warning. Qemu says the card is a SD card, and SD spec doesn't define low-voltage cards, so do now pretend to be one. Signed-off-by: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6772 c046a42c-6fe2-441c-8c8c-71466251a162
* Enable SD card on creation.balrog2008-06-021-0/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4640 c046a42c-6fe2-441c-8c8c-71466251a162
* Add basic OMAP2 chip support.balrog2008-04-141-22/+29
| | | | | | | | | | Add the OMAP242x (arm1136 core) initialisation with basic on-chip peripherals and update OMAP1 peripherals which are re-used in OMAP2. Make palmte.c and sd.c errors go to stderr. Allow disabling SD chipselect. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4213 c046a42c-6fe2-441c-8c8c-71466251a162
* Implement SD CMD8 and R7 from the newer SD Physical Spec Version 2.00.balrog2007-12-241-5/+38
| | | | | | | | Remove bogus setting of bits 63 of R2 type responses. Make some constants static to allow definitions by the same name for SDIO. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3850 c046a42c-6fe2-441c-8c8c-71466251a162
* Add "cache" parameter to "-drive" (Laurent Vivier).balrog2007-12-241-21/+19
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3848 c046a42c-6fe2-441c-8c8c-71466251a162
* Don't claim SD card supports voltages linux claims are below defined voltage ↵balrog2007-12-041-1/+1
| | | | | | range. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3772 c046a42c-6fe2-441c-8c8c-71466251a162
* Scale TSC2102 touchscreen pressure value more realistically (still could be ↵balrog2007-11-251-1/+1
| | | | | | | | | better). PalmOS 5.2.1 now fully boots. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3741 c046a42c-6fe2-441c-8c8c-71466251a162
* Partial SD card SPI mode support.pbrook2007-11-241-3/+84
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3731 c046a42c-6fe2-441c-8c8c-71466251a162
* Add statics and missing #includes for prototypes.pbrook2007-11-181-4/+4
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3683 c046a42c-6fe2-441c-8c8c-71466251a162
* Better STOPINTR bit semantics in the PXA2xx DMA.balrog2007-11-171-1/+0
| | | | | | | | Don't error out on reading GPCR register, just warn (Thorsten Zitterell). Don't zero a memory that's already zeroed. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3676 c046a42c-6fe2-441c-8c8c-71466251a162
* Break up vl.h.pbrook2007-11-171-0/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3674 c046a42c-6fe2-441c-8c8c-71466251a162
* sd.c build fix.pbrook2007-11-171-3/+3
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3673 c046a42c-6fe2-441c-8c8c-71466251a162
* Convert SD cards code to use qemu_irq too.balrog2007-11-171-18/+12
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3671 c046a42c-6fe2-441c-8c8c-71466251a162
* find -type f | xargs sed -i 's/[\t ]$//g' # on most filesths2007-09-161-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162
* Re-add clearing of the APP_CMD flag that somehow got lost.balrog2007-07-301-2/+3
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3094 c046a42c-6fe2-441c-8c8c-71466251a162
* SD card emulation (initial implementation by Andrzei Zaborowski).pbrook2007-04-061-0/+1508
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2620 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud