Hi, Zhenlei Huang <z...@freebsd.org> wrote in <6b9a293f-18cf-4fb2-b095-bc468354b...@freebsd.org>:
zl> I'm recently working on cleaning up malloc(M_WAITOK), and found that the sys/dev/usb zl> stack is also used by bootloader. Currently stand/usb fails to compile ( since the zl> commit 9e4e7bcaef3f 2022/8/23 ) and I have some WIP patches. I do not find a good zl> page about its usage. How can I test stand/usb ? Or it has no usage any more and should zl> be retired ? The stand/usb directory is used to build the libusbboot.a library containing the devsw for umass(4). The following patch (against a bit old tree) should fix the build errors at least: https://people.allbsd.org/~hrs/FreeBSD/kshim-fix.20240702-1.diff To compile a loader with libusbboot.a, you need to build a libusbboot.a with some flags first and link it with a loader. On the loader side, you need to edit conf.c and Makefile. The above patch includes changes for i386/loader, and the following command lines should build both (MK_LOADER_ZFS=no because libusbboot.a is too large): # cd /usr/src/stand/usb/tools && make && make install % cd /usr/src/stand/usb && \ make obj && \ make -DHAVE_UMASS_LOADER -DHAVE_EHCI depend && \ make -DHAVE_UMASS_LOADER -DHAVE_EHCI % cd /usr/src/stand/i386/loader && \ make obj && \ make MK_LOADER_ZFS=no depend && \ make MK_LOADER_ZFS=no # cd /usr/src/stand/i386/loader && \ make MK_LOADER_ZFS=no DESTDIR=/tmp install and you should be able to find a legacy BIOS loader in /tmp/boot/loader. I did not test whether the build result works actually, though. Note that the first command builds "sysinit" tool and installs it into /usr/bin. You can remove it after testing. Also note that the kernel source files used by ones under usb/ will use a different malloc implementation defined in kshim/bsd_kernel.[ch]. So, malloc(9) flags are simply ignored. If your work intends to check if rewriting of malloc(M_WAITOK) works or not, I think you can consider it does not affect the loaders using the libusbboot library. Although the files under kshim/ and usb/ are not maintained well, I personally think they are still worth keeping. -- Hiroki
pgp_W6sdZrTM9.pgp
Description: PGP signature