Services - tools - models - for embedded software development
Embecosm divider strip
Prev  Next

4.7.7.  Reading and Writing Memory

The m and M packets respectively read and write blocks of memory, with the data represented as hexadecimal characters. The processing is provided by rsp_read_mem () and rsp_write_mem ().

4.7.7.1.  Reading Memory

The syntax of the packet is m,addr,len:. sscanf () is used to break out the address and length fields (both in hex).

The reply packet is a stream of bytes, starting from the lowest address, each represented as a pair of hex characters. Each byte is read from memory using the simulator function eval_direct8 (), having first verified the memory area is valid using verify_memoryarea ().

The packet is only sent if all bytes are read satisfactorily. Otherwise an error packet, "E01" is sent. The actual error number does not matter—it is not used by the client.

[Caution]Caution

The use of eval_direct8 () is not correct, since it ignores any caching or memory management. As a result the current implementation is only correct for configurations with no MMU or cache.

4.7.7.2.  Writing Memory

The syntax of the packet is m,addr,len: followed by the data to be written as a stream of bytes, starting from the lowest address, each represented as a pair of hex characters. sscanf () is used to break out the address and length fields (both in hex).

Each byte is written to memory using set_program8 () (which ignores any read only constraints on the modeled memory), having first verified that the memory address is valid using verify_memoryarea ().

If all bytes are written successfully, a reply packet "OK" is sent. Otherwise an error reply, "E01" is sent. The actual error number does not matter—it is not used by the client.

[Caution]Caution

The use of set_program8 () is not correct, since it ignores any caching or memory management. As a result the current implementation is only correct for configurations with no MMU or cache.

Embecosm divider strip