ChorusOS 4.0 Porting Guide

Binaries

The binDesc array points to an array of BinDesc structures. Each structure describes an absolute executable binary involved in the system deployment procedure, such as a bootconf, bootstrap, microkernel, or a driver. These binaries are part of the system image.

typedef struct BinDesc {     
                char*        name;      /* binary symbolic name */     
                int          firstSeg;  /* first segment index */     
                int          lastSeg;   /* last segment index */     
                KnPc         entry;     /* binary entry point */     
                BinType      type;      /* binary type */     
                BinMode      mode;      /* binary loading mode */     
                void*        actor;     /* private for the u-kernel */ 
} BinDesc;

Each binary is composed of a set of segments. The firstSeg and lastSeg fields specify the range of segments within the array of segment descriptors, pointed to by segDesc, that store the binary described by BinDesc.

The type field specifies the binary's type and is set to one of the binType values listed in Table 2-2.

Table 2-2 binType Values
BinType Value Type of Binary
 BIN_BOOTCONF bootconf
 BIN_BOOTSTRAP bootstrap program
 BIN_REBOOT reboot program
 BIN_DBG_AGENT system debug agent
 BIN_DBG_DRIVER debug agent communication driver
 BIN_KERNEL microkernel
 BIN_DRIVER a ChorusOS device driver
 BIN_SUPERVISOR a supervisor actor
 BIN_USER a user actor

BinType values are defined in such a way that:

The mode specifies the binary activation mode and can be any combination of the BinMode flags listed in Table 2-3.

Table 2-3 BinMode Flags
BinMode Flag Meaning
 BIN_DEBUGGED The binary must be launched in debug mode.
 BIN_STOPPED The binary must be loaded but not started.

These flags only have meaning for BIN_SUPERVISOR and BIN_USER binaries. The value of mode is ignored for all other binary types.

numBins specifies the number of elements in the array pointed to by binDesc.

segDesc points to an array of segment descriptors. Each item in the array is a SegDesc data structure and describes a segment of the system image.SegDesc is declared in ~nucleus/sys/common/src/lib/bki/bki.h.

typedef struct SegDesc {     
                VmAddr      kaddr;  /* image address */     
                VmAddr      vaddr;  /* execution address (from link editor) */     
                VmSize      ksize;  /* image size */     
                VmSize      vsize;  /* execution size */     
                SegType     type;   /* code or data */     
                SegSpace    space;  /* address space type */ 
} SegDesc;

The descriptor specifies two things:

The segment image is stored in the memory bank containing the segment's binary. When the memory bank is installed at the required address, as specified in the BankDesc structure, the segment image can be found at kaddr. The ksize field specifies the size of the segment image contained in the memory bank.

When executed, the segment must be installed at the address specified by the vaddr field and its size must be equal to vsize. If vsize is greater than ksize, the memory from vaddr+ksize to vaddr+vsize must be initialized to zero.

The space field indicates whether a segment belongs to the initial address space. It can be set to one of the values listed in Table 2-4.

Table 2-4 SegSpace Values
SegSpace Value Meaning
 SEG_KSP segment belongs to the initial kernel address space
 SEG_VIRTUAL segment does not belongto the initial kernel address space

Only binaries of the BIN_ACTOR type can hold SEG_VIRTUAL segments.

The value of the type field can be any combination of the bits listed in Table 2-5.

Table 2-5 SegType Bit Values
SegType Bit Meaning
 SEG_XIP Segment must be executed at its place in the memory bank
 SEG_EXEC Segment contains instructions
 SEG_READ Segment contains read-only data
 SEG_WRITE Segment contains write data

If a segment is executable in place (XIP), and belongs to the initial kernel address space (for example, the SEG_XIP bit is set in the type field and the space field is equal to SEG_KSP), the segment's execution address will be the same as the segment's image address and the segment's execution size will be equal the segment's image size. Therefore, when a memory bank is installed at the address specified by its descriptor (BankDesc::vaddr), all XIP KSP segments that belong to the memory bank will have no particular installation procedure and will be ready for execution.

numSegs specifies the number of elements in the array pointed to by SegDesc.