Main Page | File List | Globals | Related Pages

device.c File Reference

VDevice methods. More...

Go to the source code of this file.

Functions

VDevice * vdev_new (char *name, int base, int size, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset, VDevFP_RegName reg_name)
void vdev_construct (VDevice *dev, char *name, int base, int size, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset, VDevFP_RegName reg_name)
void vdev_destroy (void *dev)
int vdev_name_cmp (AvrClass *c1, AvrClass *c2)
int vdev_addr_cmp (AvrClass *c1, AvrClass *c2)
uint8_t vdev_read (VDevice *dev, int addr)
void vdev_write (VDevice *dev, int addr, uint8_t val)
void vdev_reset (VDevice *dev)
void vdev_set_core (VDevice *dev, AvrClass *core)
AvrClass * vdev_get_core (VDevice *dev)
int vdev_get_base (VDevice *dev)
int vdev_get_size (VDevice *dev)
char * vdev_get_name (VDevice *dev)
char * vdev_get_reg_name (VDevice *dev, int addr)


Detailed Description

VDevice methods.

These functions are the base for all other devices mapped into the device space.

Definition in file device.c.


Function Documentation

VDevice* vdev_new char *  name,
int  base,
int  size,
VDevFP_Read  rd,
VDevFP_Write  wr,
VDevFP_Reset  reset,
VDevFP_RegName  reg_name
 

Create a new VDevice.

Definition at line 62 of file device.c.

References avr_new, class_overload_destroy(), vdev_construct(), and vdev_destroy().

void vdev_construct VDevice *  dev,
char *  name,
int  base,
int  size,
VDevFP_Read  rd,
VDevFP_Write  wr,
VDevFP_Reset  reset,
VDevFP_RegName  reg_name
 

Constructor for a VDevice.

Definition at line 76 of file device.c.

References avr_error, and class_construct().

Referenced by adc_construct(), adc_intr_construct(), ocreg16_construct(), port_construct(), spi_construct(), spi_intr_construct(), timer0_construct(), timer16_construct(), timer_intr_construct(), uart0_construct(), uart0_intr_construct(), usb_construct(), usb_intr_construct(), and vdev_new().

void vdev_destroy void *  dev  ) 
 

Destructor for a VDevice.

Definition at line 97 of file device.c.

References class_destroy().

Referenced by adc_destroy(), adc_intr_destroy(), port_destroy(), spi_destroy(), spi_intr_destroy(), timer0_destroy(), timer_intr_destroy(), uart_destroy(), uart_intr_destroy(), usb_destroy(), usb_intr_destroy(), and vdev_new().

int vdev_name_cmp AvrClass *  c1,
AvrClass *  c2
 

Compare the names of 2 devices.

Parameters:
c1 The first device.
c2 is a string and not an AvrClass object, because this function is called by dlist_lookup() which passes two AvrClass pointers. So the string is casted to an *AvrClass.
Definition at line 112 of file device.c.

Referenced by mem_get_vdevice_by_name().

int vdev_addr_cmp AvrClass *  c1,
AvrClass *  c2
 

Checks if a address is in the device's address range.

Parameters:
c1 AvrClass to check.
c2 The address to check.
Returns:
The different between the device's address bounds and c2 or if c2 is within the address range 0.
Note:
When comparing an addr, c2 is really just a pointer (see vdev_name_cmp() for details) to int and then we see if d1->base <= addr < (d1->base+d1->size).
Definition at line 129 of file device.c.

Referenced by mem_get_vdevice_by_addr().

uint8_t vdev_read VDevice *  dev,
int  addr
 

Reads the device's value in the register at addr.

Definition at line 147 of file device.c.

Referenced by mem_io_fetch(), and mem_read().

void vdev_write VDevice *  dev,
int  addr,
uint8_t  val
 

Writes an value to the register at addr.

Definition at line 154 of file device.c.

Referenced by mem_write().

void vdev_reset VDevice *  dev  ) 
 

Resets a device.

Definition at line 161 of file device.c.

void vdev_set_core VDevice *  dev,
AvrClass *  core
 

Set the core field.

Definition at line 168 of file device.c.

AvrClass* vdev_get_core VDevice *  dev  ) 
 

Get the core field.

int vdev_get_base VDevice *  dev  ) 
 

Get the device's base address.

Definition at line 178 of file device.c.

int vdev_get_size VDevice *  dev  ) 
 

Set the device's size (the number of bytes of the address space it consumes).

Definition at line 186 of file device.c.

char* vdev_get_name VDevice *  dev  ) 
 

Get the device's name.

Definition at line 193 of file device.c.

Referenced by mem_io_fetch().

char* vdev_get_reg_name VDevice *  dev,
int  addr
 

Get the name of a device's register name associated with the given address.

Definition at line 201 of file device.c.

Referenced by mem_io_fetch().


Automatically generated by Doxygen 1.3.8 on 11 Aug 2004.