Hardware resources are not able to move and are always located at the same place. If they grow, they grow one container at a time (i.e. when new disks or pluggable memory banks are added to the system). Hardware resource containers may move by replacing a whole container by another. So, usually, hardware containers will use a fixed allocator.
The hardware resources exported by the kernel are arranged as
recursive containers starting from Node. See
figure
.
Hardware resource containers employ fixed allocators because they are usually unable to grow2.15.
The fixed allocator is not given to the container (it will be given to
constructors in each subclass of HWCompResource, instantiated for
the contained element class).
<Off hardware resource container. >= (U->)
// A hardware resource container. Units will be allocated
// within it.
class off_HWCompResource : public off_CompResource {
protected:
// Creates a HWCompResource.
off_HWCompResource(const off_Protection &p,
const off_prtl_id_t &domain,
const off_prtl_id_t &id,
const off_magic_t magic ):
off_CompResource(p,domain,id,magic)
{do_debug(putchar('h'));}
};
Definesoff_HWCompResource(links are to index).
<Off hardware resource container dependencies. >= (U->) #include <klib/ids.h> // for off_eu_id_t #include <flux/debug.h> // for do_debug et al. #include <klib/prot.h> // for off_Protection et al. #include <klib/CompResource.h> // for CompResource
Hardware resource units use off_id_t identifiers as remaining
system resources do. The offset matches the resource physical name,
i.e. that understood by the hardware.
<Off hardware resource unit. >= (U->)
// A hardware resource unit.
// Uses virtualized identifiers <container id><hw id>
// and a fixed allocation scheme.
class off_HWResUnit : public off_ResUnit {
protected:
// Constructs a hardware resource unit.
off_HWResUnit(const off_Protection &p,const off_prtl_id_t &domain,
const off_id_t &id, const off_magic_t magic,
off_HWCompResource *container ) :
off_ResUnit(p,domain,id,magic,container)
{;}
// Pre-initializes a hardware resource unit.
off_HWResUnit(const off_id_t &id,
const off_magic_t magic,
off_HWCompResource *container ) :
off_ResUnit(id,magic,container)
{;}
// Creates an already pre-initialized hw resource unit.
off_HWResUnit(const off_Protection &p, const off_prtl_id_t &domain ):
off_ResUnit(p,domain)
{;}
public:
<Other public methods of off_HWResUnit. >
};
Definesoff_HWResUnit(links are to index).
<Off hardware resource unit dependencies. >= (U->) #include <klib/ids.h> // for off_eu_id_t #include <klib/prot.h> // for off_Protection #include <klib/ResUnit.h> // for off_ResUnit #include <klib/HWCompResource.h> // for off_HWCompResource
Hardware resource units can be used as machine addresses. It is a convenient implicit cast to the machine dependent name.
<Other public methods of off_HWResUnit. >= (<-U)
operator vm_offset_t(void) const { return get_id(); }
\subsection{Hardware resources for plain users}
Users can ask for the identifier of a given resouce unit.
<Off hardware resource unit for users.>= (U->)
class off_uHWResUnit : public off_uResUnit {
public:
off_eu_id_t get_id(const off_Rights &r) const;
};
Definesoff_uHWResUnit(links are to index).
Compound hardware resources do not export anything.
<Off hardware resource container for users. >= (U->)
class off_uHWCompResource : public off_uCompResource {
public:
};
Definesoff_uHWCompResource(links are to index).
\subsection{Hardware resources \cpp{} source files}
Hardware resource container definitions are kept in
klib/HWCompResource.h and klib/HWCompResource.C.
<HWCompResource.h*>= <Read the literate code instead warning. > #ifndef __OFF_HW_COMP_RESOURCE_H #define __OFF_HW_COMP_RESOURCE_H 1 <Off hardware resource container dependencies. > #ifdef __KERNEL__ <Off hardware resource container. > #endif // __KERNEL__ <Off hardware resource container for users. > #endif // __OFF_HW_COMP_RESOURCE_H
<HWCompResource.C*>= <Read the literate code instead warning. > #include <klib/HWCompResource.h> // Exported interface
Hardware resource units are found in klib/HWResUnit.h and
klib/HWResUnit.C.
<HWResUnit.h*>= <Read the literate code instead warning. > #ifndef __OFF_HW_RES_UNIT_H #define __OFF_HW_RES_UNIT_H 1 <Off hardware resource unit dependencies. > #ifdef __KERNEL__ <Off hardware resource unit. > #endif // __KERNEL__ <Off hardware resource unit for users.> #endif // __OFF_HW_RES_UNIT_H
<HWResUnit.C*>= <Read the literate code instead warning. > #include <klib/HWResUnit.h> // Exported interface