Commit Graph

664 Commits

Author SHA1 Message Date
Travis Geiselbrecht
f537ff4f9a [lib][unittest] get unittest header working with C++ source
Needed a few cpp header guards in case it was included from C++ source.
2022-04-25 23:17:45 -07:00
Travis Geiselbrecht
5cbe21919b [fs][fat] add header guard to new iterator code header 2022-04-25 00:38:29 -07:00
Travis Geiselbrecht
e615a80993 [fs][fat] reuse directory iterator logic for files
Use the new helper class to also help reading from files efficiently.
2022-04-25 00:28:09 -07:00
Travis Geiselbrecht
b6b82852a2 [fs][fat][test] add a script to create some test block devices
Create a few file systems for fat 12, 16, and 32.
2022-04-23 00:39:33 -07:00
Travis Geiselbrecht
cad9af3420 [fs][fat] add readdir support 2022-04-23 00:27:31 -07:00
Travis Geiselbrecht
011cc61478 [fs][fat] break the dir entry code into a helper routine
Now extract the code to step one entry into a directory into a separate
routine so it can be reused for search and readdir code.
2022-04-22 23:43:30 -07:00
Travis Geiselbrecht
375f5fbfe3 [fs][fat] revamp the directory walk code
Use a new directory iterator routine that tracks the offset within the
directory and handles transitions between sectors and clusters.
Redo the entry parsing code to make a single pass across the long file
names to handle crossing sector boundaries.
2022-04-22 23:03:14 -07:00
Travis Geiselbrecht
9c1c0c6e3f [fs][fat] add a single mutex around the whole FS 2022-04-22 20:27:23 -07:00
Travis Geiselbrecht
ada94e94c7 [fs][fat] get the scaffolding in place for opendir/readdir/closedir
Currently returns a dir handle that reads nothing.
2022-04-22 20:27:23 -07:00
Travis Geiselbrecht
1191f3a601 [lib][fat] restructure directory code
Move the directory handling code to dir.cpp
Handle walking the entire directory structure
Make file open be a much simpler function that just calls dir routines

TODO:
properly deal with FAT16 and FAT12 root directories
remove runtime mallocs in dir routines
2022-04-22 00:46:44 -07:00
Travis Geiselbrecht
b300a95ab4 [fs][fat] split the logic into more files, change fat detection logic
Generally split the driver into more files for future expansion.
Follow the FAT spec more closely to determine FAT type.
2022-04-21 23:06:18 -07:00
Travis Geiselbrecht
3229494b3b [fs][fat] rename from fat32 to simply fat
It also handles fat16 and (soon) fat12.
2022-04-21 21:37:34 -07:00
Travis Geiselbrecht
fe2a370171 [fs][fat] general C++ificatition of the code and a bit of cleanup 2022-04-21 21:31:01 -07:00
Travis Geiselbrecht
d829ad24ef [fs][fat] fix up the mount and read logic in fat32
Now seems to be capable of mounting a simple fat32 volume and
successfully reading a single file in the root directory that spans a
few 512 byte clusters.
2022-04-19 00:02:23 -07:00
Travis Geiselbrecht
d4969ccb3c [fs][fat32] trivially convert to C++ 2022-04-18 22:24:27 -07:00
Travis Geiselbrecht
fdb027fe7b [lib][bcache] add C++ header guards 2022-04-18 22:24:02 -07:00
Travis Geiselbrecht
c7bef34590 [lib][fs] fix path parsing bug
If two mount points had similar names but one was longer, the path
matching logic would be triggered on the shorter name.

ie, /foo and /foo2 were illegal, since /foo2 path matching would match
against /foo. Tighten the logic a bit to match against the matching
element of the passed in path.

Note: heirarchial path matching still works, so /foo/bar/baz will match
against a mount point at /foo/bar. Debatable if heirarchial mount points
should work at the moment with this simple logic, but it's there for
now.
2022-04-18 21:32:57 -07:00
Travis Geiselbrecht
b88d9e5df5 [lib][fs] add path normalization tests, add few shell commands
Move the test normalization routine into a separate test file.
Add shell commands to list registered file systems and mount points.
2022-04-18 21:04:51 -07:00
Travis Geiselbrecht
6ad3643165 [lib][minip] add an arg to the ethernet transmit callback
Already had the registration hook for it, but was never used.
2022-03-19 15:06:57 -07:00
Travis Geiselbrecht
fe28bd8a95 [lib][minip] add a mechanism to wait for the stack to be configured
Configured in this case means an ip address assigned and a nic
installed.
2022-03-19 14:46:01 -07:00
Travis Geiselbrecht
9caf62273c [lib][minip] start of TCP connect state machine
A few miscellaneous tweaks outside of that.
2022-03-19 14:43:55 -07:00
Travis Geiselbrecht
dc09bac586 [lib][elf] tweak to a printf to be more useful 2022-03-13 13:49:28 -07:00
Pedro Falcato
a9a631152f [fdtwalk] Fix a bug in #address-cells parsing
Fixes issue #314
2022-02-13 14:00:22 -08:00
Travis Geiselbrecht
06ab680159 [lib][fdtwalk] add support to return the io/mmio pci aperture as well
FDT encodes the range of available mmio and io ports that the PCI bus
can use to map bars. Return this information out of the FDT walker
helper routines to feed into the PCI bus manager in the future.
2022-02-06 19:46:39 -08:00
Travis Geiselbrecht
9d94fac5e3 [minip][dhcp] convert the dhcp utility into a C++ class
Mostly jsut a consolidation of what was already an object oriented
piece of code.
2021-12-31 20:37:40 -08:00
Travis Geiselbrecht
9e80081ea6 [minip] fix warning in new changes
Building with -Werror locally.
2021-12-31 20:37:40 -08:00
Travis Geiselbrecht
35da2d1260 [minip][dhcp] spiff up the state machine to handle more edge cases
-Add TAP option to scripts/qemux86
2021-12-31 17:23:57 -08:00
Travis Geiselbrecht
b5a9c2d8b2 [lib][minip] a few fixes
-Add C++ header guards around the public api.
-Fix a divide by zero bug in the test console routine.
-Add a new pktbuf api to assist with resetting a pktbuf back to default
values for reuse in an ethernet driver.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
06105c5835 [lib][minip] fix a bug in the dhcp code
Minor bug where it would get the mac address out of sync with what the
hardware really has.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
fa9a0a0683 [lib][cpp] add a type_traits header
mostly for std::move and friends.
2021-12-27 19:49:09 -08:00
Travis Geiselbrecht
2bb32fe813 [libc][assert] add __PRINTFLIKE to assert_fail_msg()
Fix a warning as a result of this.

fixes issue #302
2021-11-12 22:07:14 -08:00
Travis Geiselbrecht
c9eae714db [platform][qemu-virt-riscv] pick the PCIE ecam out of FDT and initialize PCI bus 2021-11-12 21:23:09 -08:00
Travis Geiselbrecht
b01f7083eb [lib][fdtwalk] add a callback hook to pass back pci-express information
At the moment only picks out the ECAM aperture and start/end bus
information, but enough to bootstrap the pci bus.
2021-11-12 21:05:40 -08:00
Travis Geiselbrecht
5b1041748e [libc] flesh out inttypes.h a bit more 2021-11-12 20:44:47 -08:00
Travis Geiselbrecht
ff0f09ae4d [lib][acpi_lite] add definition of MCFG table
MCFG describes the PCIe memory configuration region. Add support for
this table and print the information on boot on PC.
2021-11-11 01:00:18 -08:00
Travis Geiselbrecht
9de18e0828 [lib][acpi_lite] get acpi_lite building and working
Didn't require much work to port to LK, since the zircon kernel is
fairly close.

Issue #310
2021-11-11 00:16:40 -08:00
Travis Geiselbrecht
7d95b64e7e [lib][acpi_lite] import from fuchsia repository
Import verbatim at fuchsia repository at commit 645dbffdfbf52f72491187a1c59af1a677e3dd00
which is the initial commit before it was more excessively converted to
fuchsia style C++.

Issue #310
2021-11-11 00:08:33 -08:00
Travis Geiselbrecht
1550939102 [libc][inittypes] add entry for PRIxPTR 2021-11-11 00:03:39 -08:00
Travis Geiselbrecht
552606651c [lib][console] include stdalign.h and use alignof/alignas
Instead of manually calling out the alignment to a void *, use alignas
to the real type.
2021-11-09 23:29:20 -08:00
Travis Geiselbrecht
fcb65c9a88 [dev/lib][warnings] fix -Wmissing-declarations warnings in dev/ and lib/ 2021-10-21 23:16:20 -07:00
Travis Geiselbrecht
20af129a81 [lib][fs] error code for null from malloc 2021-09-18 14:39:59 -07:00
Travis Geiselbrecht
89f9805277 [lib][console] move the state of the console into an object
This will allow in the future multiple instances of it to be active at
at a time. Place the current console in a new TLS slot per thread so
threads created as a side effect of console commands can properly run
commands.
2021-05-29 00:52:47 -07:00
Travis Geiselbrecht
08aeb5a6ad [libc] fix the extension routine that adds entropy to the random pool
Worked for short entropy but actually would end up zeroing out the new
entropy word.
2021-05-26 02:15:59 -07:00
Travis Geiselbrecht
5a3d51e3e7 [assert] fix up a few places broken at DEBUG=0 after recent assert changes
Forgot to test at DEBUG=0. Both of these are basically cases where
the new DEBUG_ASSERT_COND should be used, since the default DEBUG_ASSERT
will now always emit code that gets cleaned up in the optimizer.
2021-04-02 20:16:53 -07:00
Travis Geiselbrecht
897240eb43 [lib][unittest] more improvements from zircon
Have the msg argument be optional in C++.
2021-04-02 19:28:58 -07:00
Travis Geiselbrecht
9a796e868a [assert] update the assert macros
Pull some assert macro improvements back from zircon.

Added new variants that let you pass an arbitrary message.
Move most of the inner routine into a helper, makes for slightly
smaller codegen.
2021-04-02 19:28:58 -07:00
Travis Geiselbrecht
ebdc1ea077 [lib][libcpp] move c++ specific shims out of libc and heap
Consolidate into a single library. Also renames legacy new.h to
the more standard new.

Possible that some C++ code will need to get this added to their
MODULE_DEPS.
2021-04-02 19:28:58 -07:00
Travis Geiselbrecht
c5ef3165e4 [libc] add LLONG_* to limits.h 2021-04-02 19:28:58 -07:00
Michael Bishop
41f651268b [libc] allow arch string rules to be missing
[elf] add the constant for VC4
2021-04-01 21:34:29 -07:00
Travis Geiselbrecht
e3a43bb899 [lib][unittest] spiff up the unittest lib
Roll some improvements back from zircon kernel.
2021-03-30 02:48:59 -07:00