Space.c(4dsp)


Space.c -- configuration-dependent kernel module data structure initializations

Description

One of the Installable Driver/Tunable Parameters kernel configuration files, a Space.c file, contains storage allocations and initializations for data structures associated with a kernel module, when the size or initial value of the data structures depend on configurable parameters, such as the number of subdevices configured for a particular device or a tunable parameter. For example, the Space.c file gives a non-autoconfigured driver the ability to allocate storage only for the subdevices actually being configured, by referencing symbolic constants defined in the config.h file.

When the Space.c component of a module's Driver Software Package (DSP) is installed, idinstall(1M) stores the module's Space.c file information in /etc/conf/pack.d/module-name/space.c, where module-name is the name of the module being installed.

Package scripts should never access space.c files directly; use the idinstall command instead.

For new modules with entry-type 1 (see Interface(4dsp)), such as DDI 8 drivers, the only parameter defined for the Space.c file is:

   #define MODNAME		Logical name for the module
The rest of this page applies only to entry-type 0 modules.

Entry-type 0 modules may #include the config.h header file, which is a temporary file created in the /etc/conf/cf.d directory during the system reconfiguration process. This file contains #define statements that can be used to specify the following information about the module:

Per module #defines:

   ---------------------------------------------------------------
   #define  PRFX          Set to 1 if module is configured
   #define  PRFX_MODNAME  Logical name for the module
   #define  PRFX_CNTLS    Number of configured entries in System file
   #define  PRFX_UNITS    Number of subdevices (sum of unit fields)
   #define  PRFX_BMAJORS  Number of block major numbers supported
   #define  PRFX_BMAJOR_0 Block major numbers supported; the first
                                major is PRFX_BMAJOR_0, the second
                                PRFX_BMAJOR_1, and so forth
   #define  PRFX_CMAJORS  Number of character major numbers supported
   #define  PRFX_CMAJOR_0 Character major numbers supported; the first
                                major is PRFX_CMAJOR_0, the second
                                PRFX_CMAJOR_1, and so forth

PRFX_CNTLS is only generated for non-autoconfig hardware modules (h flag in Master file and autoconf field N in Drvmap file). PRFX_UNITS is not generated for autoconfig drivers (autoconf field Y in Drvmap file). PRFX_BMAJORS is only generated for block device drivers (b flag in Master file). PRFX_CMAJORS is only generated for character device drivers (c flag in Master file).

PRFX_MODNAME is the name from the $name line in the Master file, if any; otherwise, the module-name field is used.

Per instance #defines (PRFX_0 represents the first configured instance, followed by PRFX_1, and so on if more than one instance is configured) are generated for non-autoconfig hardware modules:

   ----------------------------------------------------------------
   #define  PRFX_0        Unit field value
   #define  PRFX_0_VECT   Interrupt vector used
   #define  PRFX_0_TYPE   Interrupt vector type
   #define  PRFX_0_IPL    Interrupt priority level
   #define  PRFX_0_SIOA   Starting input/output address
   #define  PRFX_0_EIOA   Ending input/output address
   #define  PRFX_0_SCMA   Starting controller memory address
   #define  PRFX_0_ECMA   Ending controller memory address
   #define  PRFX_0_CHAN   DMA channel used (-1 if none)

Because the module is installed as an object file, the module itself can not reference the #defines for the configurable device parameters in config.h. However, the module's Space.c is a C language source file, and as such, can define variables which can take on the values of the #defines in config.h. When the next system configuration is built, the idbuild(1M) command uses the list of arguments to cc(1) defined in /etc/conf/cf.d/deflist to compile the module's Space.c file before linking the module to the kernel.

Examples

#include <config.h>
.
.
.
struct strtty lp_tty[LP_CNTLS]; /* tty structs for each device */
time_t last_time[LP_CNTLS]; /* output char watchdog timeout */
.
.
.
struct lpcfg lpcfg[LP_CNTLS] = {
0, /* state */
LP_0_SIOA+0, /* data register port address */
LP_0_SIOA+1, /* status register port address */
LP_0_SIOA+2, /* control register port address */
LP_0_VECT /* interrupt vector */
#ifdef LP_1
,
/* next structure */
0,
LP_1_SIOA+0,
LP_1_SIOA+1,
LP_1_SIOA+2,
LP_1_VECT
#endif /* LP_1 */
#ifdef LP_2
,
/* next structure */
0,
LP_2_SIOA+0,
LP_2_SIOA+1,
LP_2_SIOA+2,
LP_2_VECT
#endif /* LP_2 */
};

References

bcfg(4dsp), idbuild(1M), Interface(4dsp), Master(4dsp), System(4dsp)

Notices

The following two #defines are generated for the Space.c file for hardware modules only if their values are identical for all instances:
   #define  PRFX_CHAN     DMA channel used (-1 if none)
   #define  PRFX_TYPE     Interrupt vector type used
   #define  PRFX_CPUBIND  CPU binding for module; -1 if unbound

25 April 2004
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004