675 Commits

Author SHA1 Message Date
Travis Geiselbrecht
469b0b73f6 [lib][elf] add C++ header guards 2022-05-13 01:04:05 -07:00
Travis Geiselbrecht
4a7c0ae925 [fs][fat] fix an incorrect assert 2022-05-13 01:03:15 -07:00
Travis Geiselbrecht
d525a5f7b5 [fs][fat][test] pass in the path to the test dir so files can be included correctly
Due to the way INCBIN works, the full path relative to the root of the
assembler instance must be used, so pass in the full path as a define.
2022-05-12 22:26:22 -07:00
Travis Geiselbrecht
def9bea065 [fs][fat] general fs structural improvements
Move more of the driver into a proper object oriented model.
Start to build the structure to track open file/dirs so as to
allow multiple open instances share the same underlying object.
2022-05-12 20:26:52 -07:00
Travis Geiselbrecht
89f8e62587 [fs][fat][test] add some more test code
Also create a large zero filled file and add it to the test fs, to try
to make sure there's at least one file that crosses a FAT sector.
2022-04-29 22:12:30 -07:00
Travis Geiselbrecht
144f608bce [fs][fat] add support for FAT12
The 12 bit fat parsing code is a little tricky.
2022-04-29 22:10:11 -07:00
Travis Geiselbrecht
40f516c15a [lib][unittest] tweak the command line to let you list and selectively run individual tests 2022-04-29 20:39:05 -07:00
Travis Geiselbrecht
1c9caf9f64 [fs][fat][test] start of unittests for fat file system
Requires a block device be present with a pre-formatted fs, but
should fail gracefully if its not present.
2022-04-25 23:17:55 -07:00
Travis Geiselbrecht
f6f43edc3c [fs][tests] break some fs tests into their own module
Include the test modules if the overal virtual/test module is included.
Also set a new global build system var along with a configuration
variable.
2022-04-25 23:17:55 -07:00
Travis Geiselbrecht
cb5ccee400 [fs][fat] fix a bug in close_dir that forgot to delete dir nodes 2022-04-25 23:17:55 -07:00
Travis Geiselbrecht
c08d540fd6 [lib][fs] add a trace printf when unmounting 2022-04-25 23:17:45 -07:00
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