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/sys on a machine with the FreeBSD 6.0-RELEASE amd64 sources installed. This will create /usr/src/sys/dev/hptmv6 and /usr/src/sys/modules/hptmv6 and the files therein.
Edit the file /usr/src/sys/dev/hptmv6/osm_bsd.c in vi or 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,
#endif
This entire #if/#endif block 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 Makefile in /usr/src/sys/modules/hptmv6 needs 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 .uu file; as downloaded the path is ../../dev/hptmv6, which won’t work during kernel builds, since /usr/src/modules/hptmv6 isn’t the current directory. Instead, the makefile above uses ${.CURDIR}/../../dev/hptmv6, which will always resolve to the correct dev/hptmv6 path. I borrowed this form from the hptmv driver, 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 the hptmv6 driver.
Create a new kernel configuration based on GENERIC, and make the modifications as instructed in the Readme file that ships with the RocketRaid 222x driver tarball. Specifically, the changes are:
Copy the GENERIC file in /usr/src/sys/i386/conf (for i386 targets) or /usr/src/sys/amd64/conf (for amd64 targets; 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 use CUSTOM_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 amd64 targets, edit /usr/src/sys/conf/files.amd64 and 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 hptmv6
For i386 targets, replace amd64 with i386 in the file name and text.
To build the kernel module separate from the static kernel, I had to edit /usr/src/sys/modules/Makefile to add hptmv6 everywhere I found hptmv. Otherwise it’s just linked into the static kernel, and no .ko module is created.