Preparing The Highpoint RocketRaid 222x Driver Source Code
- Go to the HighPoint RocketRaid 2220 download page, and download the FreeBSD open-source driver (at the bottom of the page). Do not get the FreeBSD driver; you must download the source code. As of this writing, the latest version was 1.01.
- Extract the tarball into
/usr/src/syson a machine with the FreeBSD 6.0-RELEASE amd64 sources installed. This will create/usr/src/sys/dev/hptmv6and/usr/src/sys/modules/hptmv6and the files therein. - Edit the file
/usr/src/sys/dev/hptmv6/osm_bsd.cinvior some similar text editor. This file references a field (d_maj) in a kernel data structure (cdevsw) that is no longer used in the 6.0 kernel (see What happened to the “d_maj” member of “struct cdevsw” in CURRENT? on the FreeBSD mailing list archive). Until this broken reference is removed, the driver will not compile.As of version 1.01 of the driver source, the offending line was 1117 in
osm_bsd.c. The line number could vary with subsequent versions, but the region around the problem looks like this:#if __FreeBSD_version>501000 .d_maj = MAJOR_AUTO, #else .d_maj = HPT_DEV_MAJOR, #endifThis entire
#if/#endifblock must be removed or commented out. I prefer to comment it out, replacing the above with this:/* commented out by anelson; d_maj deprecated in 6.0 #if __FreeBSD_version>501000 .d_maj = MAJOR_AUTO, #else .d_maj = HPT_DEV_MAJOR, #endif */The
/*and*/sequences denote a comment block in C; everything between the two sequences will be ignored by the compiler. - The
Makefilein/usr/src/sys/modules/hptmv6needs to be tweaked a bit as well. Replace its contents with this, below:HPTMV6= ${.CURDIR}/../../dev/hptmv6 .PATH: ${HPTMV6} KMOD = hptmv6 SRCS = opt_scsi.h opt_cam.h bus_if.h device_if.h pci_if.h os_bsd.h os_bsd.c osm_bsd.c hptmv6_config.c OBJS = hptmv6_lib.o .if $(MACHINE_ARCH) == "amd64" HPTMV6_O = amd64-elf.hptmv6_lib.o.uu .else HPTMV6_O = i386-elf.hptmv6_lib.o.uu .endif hptmv6_lib.o: ${HPTMV6}/$(HPTMV6_O) uudecode -p < ${HPTMV6}/$(HPTMV6_O) > ${.TARGET} .include <bsd.kmod.mk>Most of the changes are cosmetic, but one important change is to the path to the
.uufile; as downloaded the path is../../dev/hptmv6, which won’t work during kernel builds, since/usr/src/modules/hptmv6isn’t the current directory. Instead, the makefile above uses${.CURDIR}/../../dev/hptmv6, which will always resolve to the correctdev/hptmv6path. I borrowed this form from thehptmvdriver, for the RocketRaid 18xx series ATA RAID cards, which was already in the kernel source tree in/usr/src/sys/modules/hptmv, and has a very similar structure to that of thehptmv6driver. - Create a new kernel configuration based on GENERIC, and make the modifications as instructed in the
Readmefile that ships with the RocketRaid 222x driver tarball. Specifically, the changes are:- Copy the
GENERICfile in/usr/src/sys/i386/conf(fori386targets) or/usr/src/sys/amd64/conf(foramd64targets; the target I’m interested in), to a new file in the same directory, with a different name. This new name will be the name of the custom kernel; I useCUSTOM_AMD64_HPTMV6. - Find the following line in the new file you copied:
device "hptmv"...Right below that line, add this line:
device "hptmv6" #HighPoint RocketRAID 222x - For
amd64targets, edit/usr/src/sys/conf/files.amd64and append the following:hptmv6_lib.o optional hptmv6 \ dependency "$S/dev/hptmv6/amd64-elf.hptmv6_lib.o.uu" \ compile-with "uudecode < $S/dev/hptmv6/amd64-elf.hptmv6_lib.o.uu" \ no-implicit-rule dev/hptmv6/os_bsd.c optional hptmv6 dev/hptmv6/osm_bsd.c optional hptmv6 dev/hptmv6/hptmv6_config.c optional hptmv6For
i386targets, replaceamd64withi386in the file name and text.
- Copy the
- To build the kernel module separate from the static kernel, I had to edit
/usr/src/sys/modules/Makefileto addhptmv6everywhere I foundhptmv. Otherwise it’s just linked into the static kernel, and no.komodule is created.