Xenomai  3.1
udd_memregion Struct Reference

Data Fields

const char * name
 Name of the region (informational but required)
 
unsigned long addr
 Start address of the region. More...
 
size_t len
 Length (in bytes) of the region. More...
 
int type
 Type of the region. More...
 

Detailed Description

UDD memory region descriptor.

This descriptor defines the characteristics of a memory region declared to the UDD core by the mini-driver. All valid regions should be declared in the udd_device.mem_regions[] array, invalid/unassigned ones should bear the UDD_MEM_NONE type.

The UDD core exposes each region via the mmap(2) interface to the application. To this end, a companion mapper device is created automatically when registering the mini-driver.

The mapper device creates special files in the RTDM namespace for reaching the individual regions, which the application can open then map to its address space via the mmap(2) system call.

For instance, declaring a region of physical memory at index #2 of the memory region array could be done as follows:

static struct udd_device udd;
static int foocard_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
udd.device_name = "foocard";
...
udd.mem_regions[2].name = "ADC";
udd.mem_regions[2].addr = pci_resource_start(dev, 1);
udd.mem_regions[2].len = pci_resource_len(dev, 1);
udd.mem_regions[2].type = UDD_MEM_PHYS;
...
return udd_register_device(&udd);
}

This will make such region accessible via the mapper device using the following sequence of code (see note), via the default ->mmap() handler from the UDD core:

int fd, fdm;
void *p;
fd = open("/dev/rtdm/foocard", O_RDWR);
fdm = open("/dev/rtdm/foocard,mapper2", O_RDWR);
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fdm, 0);

if no valid region has been declared in the udd_device.mem_regions[] array, no mapper device is created.

Note
The example code assumes that cobalt_api POSIX symbol wrapping is in effect, so that RTDM performs the memory mapping operation (not the regular kernel).

Field Documentation

◆ addr

unsigned long udd_memregion::addr

Start address of the region.

This may be a physical or virtual address, depending on the memory type.

◆ len

size_t udd_memregion::len

Length (in bytes) of the region.

This value must be PAGE_SIZE aligned.

◆ type

int udd_memregion::type

Type of the region.

See the discussion about UDD memory types for possible values.


The documentation for this struct was generated from the following file: