Where are the BSD boot/kernel components and drivers located? reddit / BSD ---------------------------------------------------------------------- AgreeableLandscape3 · 2019-06-15 05:09 Just wondering where I can find the boot and kernel components of BSD and my device drivers on a standard installation. Is there an agreed upon place for them? ---------------------------------------------------------------------- ntufar · 2019-06-15 06:28 You can start here: https://github.com/freebsd/freebsd sys/ directory is where kernel with the drivers in. ---------------------------------------------------------------------- PitifulView · 2019-06-15 06:29 I think for netbsd/x86 bios boot (gotta pick at least one example): the first 512 bytes of your hard disk contain a [very simple, assembly boot code](https://github.com/NetBSD/src/blob/trunk/sys/arch/i386/stan d/mbr/mbr.S#L127). 512 bytes is a very small amount and constrained by architecture limitations, so there's a second stage. this code looks for the partition table and finds the second stage. the second stage knows how to read the filesystem and such (the C code for it lives in a ["libsa" directory](https://github.com/NetBSD/src/tree/trunk/sys/lib/libsa) for most BSDs, or "lib standalone". it's shared by multiple architectures). At this point we have very little constraints, it runs normal C code without size constraints. In netbsd it reads the filesystem, looking for "/netbsd". This is an ELF file and the second stage bootloader has [normal C code to load ELF executables.](https://github.com/NetBSD/src /blob/trunk/sys/lib/libsa/loadfile_elf32.c) It can also load modules, which are located on netbsd on /stand/, or parse arguments. Once the ELF file is loaded into memory, we jump into the [early boot code](https://github.com/NetBSD/src/blob/trunk/sys/arch/amd64/amd64/lo core.S#L436), marked as the ELF entry point. This eventually makes its way into the kernel main function, which eventually ends in being an [infinite loop.](https://github.com/NetBSD /src/blob/trunk/sys/kern/init_main.c#L741) The driver code is usually located in the [src/sys/dev](https://github.com/NetBSD/src/tree/trunk/sys/dev) directory, with some directories attempting to put order into the madness: netbsd organizes things by bus, so you'll have PCI-related code in "pci". ---------------------------------------------------------------------- Maccraft123 · 2019-06-15 06:49 Kernel is in /boot/kernel/kernel, modules are in /boot/{modules,kernel}. ---------------------------------------------------------------------- illumosguy · 2019-06-15 07:25 > Just wondering where I can find the boot and kernel components of BSD and my device drivers on a standard installation. it varies upon the specific BSD, on NetBSD kernel by default is `/netbsd` (whereas the kernfs pseudo filesystem is mounted on /kern), while standalone modules are located at `/stand/$arch/$osver/modules`. > Is there an agreed upon place for them? Whenever you're uncertain about some default location on *BSD, looking up the `hier(7)` man page is possibly the best thing to do ---------------------------------------------------------------------- DamienCouderc · 2019-06-15 14:16 What do you call BSD ? ---------------------------------------------------------------------- practical_lem · 2019-06-15 21:16 OpenBSD has a monolithic kernel: /bsd is the default one. ---------------------------------------------------------------------- cmason37 · 2019-06-16 04:27 Just a note for anyone reading, this is only on FreeBSD