Tuesday, January 02, 2007

solaris driver

So in desperate attempt to contribute in some way, constructive way, to our release, I decided to put all my effort into making the Solaris stub driver that would later on be filled with the required content. So my hard work paid off and I found this link. It basically walks you through all the steps of creating a dummy driver for Solaris.

So after understanding that code [read: copying & pasting] , I gave gcc a chance to prove its worth. But no, I would not assist gcc by giving away the compiler flags. After a bit more of search on the web, I realized, thats the way of life. I would have to give the right compiler flags which, thanks to ReneS, I plugged in. However sun has a good coverage for gcc and cc compiler over here. In short (from the sun site above):

------------------------------------------------------------------

Use the -D_KERNEL option to indicate that this code defines a kernel module. These examples show options that are required for correct functionality of the result.

  • If you are compiling for a 64-bit SPARC architecture, use the following build commands:


    % gcc -D_KERNEL -m64 -mcpu=v9 -mcmodel=medlow -fno-pic -mno-fpu -ffreestanding -nodefaultlibs -c mydriver.c
    % /usr/ccs/bin/ld -r -o mydriver mydriver.o

    You might also want to use the -mtune=ultrasparc option and the -O2 option.

  • If you are compiling for a 64-bit x86 architecture, use the following build commands:


    % gcc -D_KERNEL -m64 -mcmodel=kernel -mno-red-zone -ffreestanding -nodefaultlibs -c mydriver.c
    % /usr/ccs/bin/ld -r -o mydriver mydriver.o

    You might also want to use the -mtune=opteron option and the -O2 option.

  • If you are compiling for a 32-bit architecture, use the following build commands:


    % gcc -D_KERNEL -ffreestanding -nodefaultlibs -c mydriver.c
    % /usr/ccs/bin/ld -r -o mydriver mydriver.o
------------------------------------------------------------------

Since I was Compiling for amd64 x86 Solaris 10, my options looked like

KERNEL_CFLAGS= -D_KERNEL -m64 -mcmodel=kernel -mno-red-zone -ffreestanding -nodefaultlibs -c mydriver.c

and lo and behold, it compiled.

so next step was to load pfil with it. And all that I understand of pfil is between the lines below.
-------------------------------





-------------------------------

No comments: