Main Page

Functions
memory.c File Reference

Go to the source code of this file.

## Functions
Memory * | mem_new (int gpwr_end, int io_reg_end, int sram_end, int xram_end)
void | mem_construct (Memory *mem, int gpwr_end, int io_reg_end, int sram_end, int xram_end)
void | mem_destroy (void *mem)
void | mem_attach (Memory *mem, int addr, char *name, VDevice *vdev, int flags, uint8_t reset_value, uint8_t rd_mask, uint8_t wr_mask)
VDevice * | mem_get_vdevice_by_addr (Memory *mem, int addr)
VDevice * | mem_get_vdevice_by_name (Memory *mem, char *name)
void | mem_set_addr_name (Memory *mem, int addr, char *name)
uint8_t | mem_read (Memory *mem, int addr)
void | mem_write (Memory *mem, int addr, uint8_t val)
void | mem_reset (Memory *mem)
void | mem_io_fetch (Memory *mem, int addr, uint8_t *val, char *buf, int bufsiz)
void | mem_dump_core (Memory *mem, FILE *f_core)

## Detailed Description

Memory access functions.

This module provides functions for reading and writing to simulated memory. The Memory class is a subclass of AvrClass.

Definition in file memory.c.

## Function Documentation

## § mem_new()

Memory* mem_new | ( | int | gpwr_end,
|  | int | io_reg_end,
|  | int | sram_end,
|  | int | xram_end
| ) |  |

Allocates memory for a new memory object.

Definition at line 66 of file memory.c.

References avr_new0, class_overload_destroy(), mem_construct(), and mem_destroy().

## § mem_construct()

void mem_construct | ( | Memory * | mem,
|  | int | gpwr_end,
|  | int | io_reg_end,
|  | int | sram_end,
|  | int | xram_end
| ) |  |

Constructor for the memory object.

Definition at line 80 of file memory.c.

References avr_error, avr_new0, and class_construct().

Referenced by mem_new().

## § mem_destroy()

void mem_destroy | ( | void * | mem | ) |

Descructor for the memory object.

Definition at line 99 of file memory.c.

References avr_free(), class_destroy(), and class_unref().

Referenced by mem_new().

## § mem_attach()

void mem_attach | ( | Memory * | mem,
|  | int | addr,
|  | char * | name,
|  | VDevice * | vdev,
|  | int | flags,
|  | uint8_t | reset_value,
|  | uint8_t | rd_mask,
|  | uint8_t | wr_mask
| ) |  |

Attach a device to the device list.

Devices that are accessed more often should be attached last so that they will be at the front of the list.

A default virtual device can be overridden by attaching a new device ahead of it in the list.

Definition at line 130 of file memory.c.

References avr_error, and class_ref().

## § mem_get_vdevice_by_addr()

VDevice* mem_get_vdevice_by_addr | ( | Memory * | mem,
|  | int | addr
| ) |  |

Find the VDevice associated with the given address.

Definition at line 159 of file memory.c.

Referenced by avr_core_add_ext_rd_wr().

## § mem_get_vdevice_by_name()

VDevice* mem_get_vdevice_by_name | ( | Memory * | mem,
|  | char * | name
| ) |  |

Find the VDevice associated with the given name.

Deprecated:

Definition at line 169 of file memory.c.

References avr_error, and dlist_lookup().

Referenced by avr_core_load_eeprom().

## § mem_read()

uint8_t mem_read | ( | Memory * | mem,
|  | int | addr
| ) |  |

Reads byte from memory and sanity-checks for valid address.

Parameters

  mem | A pointer to the memory object
  addr | The address to be read

Returns
  The byte found at that address addr

Definition at line 220 of file memory.c.

## § mem_write()

void mem_write | ( | Memory * | mem,
|  | int | addr,
|  | uint8_t | val
| ) |  |

Writes byte to memory and updates display for io registers.

Parameters

  mem | A pointer to a memory object
  addr | The address to be written to
  val | The value to be written there

Definition at line 255 of file memory.c.

## § mem_reset()

void mem_reset | ( | Memory * | mem | ) |

Resets every device in the memory object.

Parameters

  mem | A pointer to the memory object.

Definition at line 292 of file memory.c.

## § mem_io_fetch()

void mem_io_fetch | ( | Memory * | mem,
|  | int | addr,
|  | uint8_t * | val,
|  | char * | buf,
|  | int | bufsiz
| ) |  |

Fetch the name and value of the io register (addr).

Parameters

  mem | A pointer to the memory object.
  addr | The address to fetch from.
  val | A pointer where the value of the register is to be copied.
  buf | A pointer to where the name of the register should be copied.
  bufsiz | The maximum size of the the buf string.

Definition at line 330 of file memory.c.

Referenced by avr_core_io_display_names().

## § mem_dump_core()

void mem_dump_core | ( | Memory * | mem,
|  | FILE * | f_core
| ) |  |

Dump all the various memory locations to a file descriptor in text format.

Parameters

  mem | A memory object.
  f_core | An open file descriptor.

Definition at line 491 of file memory.c.

Automatically generated by Doxygen 1.8.12 on Tue Apr 18 2017.