51 Commits

Author SHA1 Message Date
Kelvin Zhang
af1f19a2cc [lib][uefi] Add interrupt based async IO support
Add a new API to bio layer(read_async) where function will
return immediately, and a callback function will be called from
interrupt context, when block driver completes the IO request.
2025-08-13 16:13:38 -04:00
Michael Bishop
d66ad44db3 bio: use shifts to divide 2025-05-06 23:40:25 -07:00
Kelvin Zhang
0c1cb6bf03 [app][uefi] Add block device protocol 2025-01-08 09:54:00 -08:00
Travis Geiselbrecht
f7d8e2300c [warnings] add -Wshadow which helps detect local variables that override globals
Nothing particularly bad showed up but cleaned up a bit of code.
2020-07-25 16:49:25 -07:00
Travis Geiselbrecht
4edb93adde [lib][console] rename some console command types to be prefixed with console_
Some of the structures, notably 'cmd', in the lib console stuff are a
little too generically named and have collided with some other code
so prefix the names a bit more cleanly with console_

The change is largely mechanical, and folks with out of tree code can
easily switch by renaming:
cmd -> console_cmd
cmd_args -> console_cmd_args
cmd_block -> console_cmd_block
console_cmd -> console_cmd_func

Apologies if this breaks you but it should be pretty easy to fix.
2020-07-25 15:59:58 -07:00
Travis Geiselbrecht
f371fa246b [arch] move the atomic ops into a separate header
Now you need to include arch/atomic.h to get to the atomic routines.
This simplifies a recusion issue in the way arch/ops.h included
arch_ops. Also just generally makes things cleaner.
2020-05-16 15:05:34 -07:00
Travis Geiselbrecht
6cb02526b7 [include][console] split lib/console.h into two
TL;DR most uses of lib/console.h -> lk/console_cmd.h

Move the part that lets a piece of code somewhere in the system to
define a console command from the actual lib/console api to start an
instance of the console. Move in almost every place the user of the
console command definition to the new header, lk/console_cmd.h which is
always in the include path.

Also remove most uses of testing for WITH_LIB_CONSOLE since you can
almost always just safely define it and then let the linker remove it.
2019-07-13 16:56:33 -07:00
Travis Geiselbrecht
cba9e47987 [license] replace the longer full MIT license with a shorter one
Used scripts/replacelic. Everything seems to build fine.
2019-07-05 17:22:23 -07:00
Travis Geiselbrecht
3699e45942 [include][lib] move most of the dangling top level include/lib/.h files into their lib
Only remaining one is console.h which is a little funny and will need to
be dealt with separately.
2019-06-19 22:44:15 -07:00
Travis Geiselbrecht
d8fa82cb91 [formatting] run everything through codestyle
Almost nothing changes here except moving braces to the same line as the
function declaration. Everything else is largely whitespace changes and
a few dangling files with tab indents.

See scripts/codestyle
2019-06-19 21:02:24 -07:00
Travis Geiselbrecht
1b7a28efb8 [include][lk] fixup lk/ include path move 2019-06-19 19:46:11 -07:00
Pibben
6a5f974ae9 [lib][bio] sub device inherits parent device erase_byte
Sub device inherits parent device erase_byte.
Nand flash device is with erase_byte = 0xFF, but in bio_publish_subdevice,
the sub device erase_byte will be with initial value 0.
When the image with the chunk of 0, the chunk is not written, but the
read value is 0xFF.

Signed-off-by: Pibben <pibben.tung@mediatek.com>
2019-04-10 01:58:12 -07:00
Travis Geiselbrecht
7bbf6d5831 [nit] fix extraneous trailing ; in CDECLS lines 2018-12-16 16:49:40 -08:00
Travis Geiselbrecht
5dea3e1933 [warnings] fix a few warnings introduced with newer version of gcc
Most of the warnings are new, such as needing to mark fallthroughs on
cases explicitly. A few are based on signed vs unsigned comparisons.

Disable one warning that was annoying about comparing null to arguments
marked nonnull.
2018-03-15 14:10:12 -07:00
Tristan Shieh
2a70c35d36 [lib][bio] fix compile warning with arch/arm64
lib/bio/bio.c:345:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Tristan Shieh <tristan.shieh@mediatek.com>
2017-10-23 00:21:16 -07:00
klemens
d0b90c2d68 [spelling] spelling-fixes. (not external/) 2016-08-25 17:30:34 -07:00
Gurjant Kalsi
62c4f983ef [bio] IOCtl to test whether the device is in linear mode. 2016-05-10 18:21:29 -07:00
Travis Geiselbrecht
ae8f548bf3 [bio] Fix a few printf format warnings.
Fix a few printf format warnings which show up in 64 bit builds.
2016-02-23 21:07:10 -08:00
Travis Geiselbrecht
2eb32a4369 [style] mass reformat all the non external code to 4 space indents
Ran everything through scripts/codestyle.space, which uses astyle
to generally follow K&R style.

Biggest non whitespace change is pulling brackets down on function
declarations, which I'm pretty ambivalent about, but astyle insists
on taking a stance
2016-02-14 12:24:01 -08:00
Gurjant Kalsi
1cca765aa4 [qspi][stm32f7] Support exiting linear mode for STM32F7 QSPI Part
Support the BIO_IOCTL_PUT_MEM_MAP ioctl. Also add tests for
entering and exiting linear mode in the bio tests.
2016-02-03 14:07:37 -08:00
Gurjant Kalsi
4560219c45 [bio][cpp] wrap bio.h with CDECLS 2015-11-12 11:19:00 -08:00
Gurjant Kalsi
d9a97e7c0d [bio][flash] Added bio ioctl to return memory mapped address without putting the device into linear mode 2015-11-11 15:31:54 -08:00
Gurjant Kalsi
3ec7c378c8 [virtio] Virtio read/write block return 0 on success instead of number of bytes transferred 2015-11-05 11:00:53 -08:00
Gurjant Kalsi
3dafd61197 [bio][spiflash] Enforce cache line aligned buffers for default read/write. Use default read hook for stm32 spiflash. 2015-11-04 17:18:24 -08:00
Gurjant Kalsi
7e0a4d3f90 [bio] Add a flag that allows devices to declare that they only deal with cache aligned blocks of memory 2015-11-04 17:18:15 -08:00
Gurjant Kalsi
2b1cd10693 [spiflash][bio][stm32f7] Fixed (sub)sector erase on spiflash device.
R=travisg@google.com, cpu@google.com
BUG=

Review URL: https://codereview.chromium.org/1410223011 .
2015-11-02 11:44:50 -08:00
Travis Geiselbrecht
80f4d7c33e [lib][bio] move #define up out of LK_DEBUGLEVEL block to work in release builds too 2015-10-27 09:59:27 -07:00
Travis Geiselbrecht
b8ee0d04b6 [lib][bio] reformat with spaces and move header into module 2015-10-23 12:27:23 -07:00
Gurjant Kalsi
33c5394df7 [stm32f756][spiflash][bio] Get the spiflash working on the STM32F756G-Eval Board 2015-10-22 16:02:32 -07:00
Gurjant Kalsi
8d7fcb24c6 [qspi][bio][debug] Fixed signed/unsigned compare warning 2015-10-16 19:07:32 -07:00
Gurjant Kalsi
e68f56fc96 [bio][debug] Check for errors in bio test when validating blocks 2015-10-16 14:50:08 -07:00
Travis Geiselbrecht
3a7dbc4fb9 [lib][bio] fix the default erase hook to not leak memory and properly return errors
Also remove the init hook requirement in the bio layer by statically
initializing the root data structure (was small anyway).
2015-10-11 18:37:27 -07:00
Travis Geiselbrecht
fab3ea81be [lib][bio] bio devices can report what their erase state is
-tweak the bio test to use it
-tweak a few drivers to set the non default (0x00 is default)
2015-10-11 18:10:17 -07:00
Gurjant Kalsi
26d49d80c6 [bio][debug][console] Added some Block I/O test routines. 2015-10-07 15:23:34 -07:00
Gurjant Kalsi
2aff01bf95 [style][bio][console] Ran Astyle on lib/bio/debug.c; priming for incoming changes. 2015-10-07 15:23:34 -07:00
Travis Geiselbrecht
3fe0794103 [lib][bio] add more asserts and change the default routines to not panic 2015-08-27 15:37:17 -07:00
John Grossman
8a7219ddb1 [lib][bio] Add erase geometry to lib/bio
Extend the block i/o system to allow registered devices to advertise
an erase geometry.  Devices which do not need to be explicitly erased
may skip this.  Extent the Zynq spiflash code to publish the erase
geometry as read from the flash device.

Signed-off-by: John Grossman <johngro@google.com>
Change-Id: I42e16fbe9a0fcf8334c317f16dea1c551c203eb2
2015-06-29 17:32:10 -07:00
John Grossman
8028f42df6 [lib][bio] Add a dump command to the bio console
Signed-off-by: John Grossman <johngro@google.com>
Change-Id: Icef8e97fae9b587e188dae6e8f367dbdf05c070c
2015-06-29 17:32:10 -07:00
Travis Geiselbrecht
dc7273c466 [lib][bio] tweak api for subdevice publishing 2014-07-23 15:22:12 -07:00
Travis Geiselbrecht
d48bbbb72d [lib][bio] add repeat debug command to crc32 2014-07-22 19:52:18 -07:00
Travis Geiselbrecht
2df6b58708 [lib][bio] add crc32 debug command
Checksums a range of a block device.
2014-07-16 16:34:44 -07:00
Travis Geiselbrecht
eb1aa836c5 [lib][bio] add a few helper block io trim routines 2014-07-15 20:07:45 -07:00
Dima Zavin
36c7735533 [libc][stdio] cleanup printf definition and clients
Move implementation to stdio.c to sit next to the other
stdio definitions that use the debug output functions. Keep
the declaration of it, though, in printf.h to sit next to
sprintf, etc.

Don't include printf.h directly in other places, rely on stdio.h
to properly pull in these functions.

Change-Id: I357cb04a5c78185b8fde908193b672326c2ee542
Signed-off-by: Dima Zavin <dima@android.com>
2013-08-05 10:04:29 -07:00
Dima Zavin
e8a9b4b7a4 [libc] move tracing out of debug into separate trace.h
Change-Id: I7476fc17b587a0ea2a42cbe3d49b72063e4c5dc8
Signed-off-by: Dima Zavin <dima@android.com>
2013-08-05 10:04:29 -07:00
Travis Geiselbrecht
a901b3bd81 [lib] move a few libs to the new init hook system 2013-08-03 15:36:53 -07:00
Travis Geiselbrecht
98b4e0938e [make] rename DEBUGLEVEL -> LK_DEBUGLEVEL, remove DEBUG define
-Remove top level DEBUG=<N> define
-Rename DEBUGLEVEL to LK_DEBUGLEVEL to be clear.
-Fix the places that used DEBUGLEVEL and the few spots that #ifdef
on DEBUG.
2013-06-07 22:27:00 -07:00
Travis Geiselbrecht
9b961b4a34 [lib] run all of lib and include through astyle 2012-10-31 21:47:17 -07:00
Travis Geiselbrecht
1262105ab9 [time] rename {big}time_t -> lk_{big}time_t
-This avoids a collision with posix time_t and makes gcc complain
less about printf format mismatches.
2012-10-06 11:22:15 -07:00
Travis Geiselbrecht
97cfd0bfa4 [make] update all of the rules.mk to use the new module system 2012-08-31 15:52:24 -07:00
Travis Geiselbrecht
affed1c106 [lib] add more references to assert.h 2012-04-23 15:52:31 -07:00