pcisim.data.bar
index
../../src/pcisim/data/bar.py

This module contains information about BAR structure.

 
Classes
       
pcisim.lib.dataword.DataWord(__builtin__.object)
BAR

 
class BAR(pcisim.lib.dataword.DataWord)
    Implements a *Base Address Register* structure.
 
@ATTRIBS
    (int) barid : bar number id in range 0-5
 
@CONSTS
    BAR0 : offset of BAR 0 in PCI Device Structure
    BAR1 : offset of BAR 1 in PCI Device Structure
    ...
    BAR5 : offset of BAR 5 in PCI Device Structure
 
 
Method resolution order:
BAR
pcisim.lib.dataword.DataWord
__builtin__.object

Methods defined here:
__init__(self, barid, memsize=16)
@PARAMS
    (int) barid : bar number id in range 0-5
    (int) memsize : memory size required for the bar
gen_size_mask(self, size)
Generates a size mask to hold specified size.
 
@PARAMS
    (int) size : size to hold.
 
@RETURN
    (int) 32bit generated size mask.
get_decoded_memsize(self)
Get BAR decoded memory size.
 
@NOTES
    Requires previous 'set_size_mask' call.
holds_address(self)
Query BAR state.
 
@RETURN
    | True : this BAR has been assigned an address.
    | False : this BAR holds a memory mask
lock_address(self, lock=True)
Locks or unlocks BAR value modifications.
set_address(self, addr)
Assign the base address to the BAR.
 
@PARAMS
    (int) addr : 32bit base address.
 
@NOTES
    This functions locks BAR value modifications.
set_size_mask(self, mask)
Set a memory size mask for the BAR.
write_size_mask(self)
Writes current set size mask to BAR value.
 
@NOTES
    This functions unlocks BAR value to future modifications.

Data and other attributes defined here:
BAR0 = 16
BAR1 = 20
BAR2 = 24
BAR3 = 28
BAR4 = 32
BAR5 = 36

Methods inherited from pcisim.lib.dataword.DataWord:
__getattr__(self, attr)
Allows point notation to be used to access fields by name.
 
@PARAMS
    (str) attr : field or attribute to get
 
@RETURNS
    (int) field value
 
@RAISES
    AttributeError if field or attribute not found
__iter__(self)
Iterate over structure fields.
 
@RETURN
    self.fields iterator.
__setattr__(self, attr, val)
Allows point notation to be used to set field value.
 
@PARAMS
    (str) attr : field or attribute to be set
    (int) val : value to set
__str__(self)
add(self, field)
Adds a field to the structure starting from bit 0.
 
@PARAMS
    (DataField) field : field to add
 
@NOTES
    Unlocks the structure if locked.
add_field(self, name, bits, *args, **kargs)
Creates a DataField and adds it to the structure starting from
bit 0.
 
@PARAMS
    (str) name : symbolic name for the field
    (int) bits : number of bits of the field
    *args : additional arguments to pass to DataField init
    **kargs : additional keyword arguments to pass to DataField init
 
@RETURN
    (DataField) added field.
 
@NOTES
    Unlocks the structure if locked.
get_bits(self)
Get structure overall bit size.
 
@RETURN
    (int) bit size.
 
@RAISES
    StructureNotLocked if lock() function was not called.
get_field(self, fieldname)
Get a field by field name.
 
@PARAMS
    (str) fieldname : name of the field to search
 
@RETURN
    (DataField) field found.
 
@RAISES
    FieldNotFound when given field name does not match any.
get_raw(self)
Get structure value as an integer value;
 
@RETURN
    (int) raw fields value.
is_locked(self)
True if structure is locked;
lock(self)
Calculates structure bitsize.
 
This method should be called after structure has been populated.
After this call, bitsize can be retrieved by get_bits() call.
set_field(self, fieldname, value)
Sets a specific field value;
 
@PARAMS
    (str) fieldname : name of the field to set
    (int) value : value to set
 
@RETURN
    (DataField) modified field.
set_raw(self, rawdata)
Set a raw value to the structure, overwriting fields value.
 
@PARAMS
    (int) rawdata : value to set

Data descriptors inherited from pcisim.lib.dataword.DataWord:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
decode_mask(mask)
Decodes BAR mask and returns required memory size.
 
@PARAMS
    (int) mask : 32 bit mask value
 
@RETURN
    (int) required BAR memory

 
Data
        __all__ = ['BAR', 'decode_mask']