This is the specification for the memory device of the Bedrock computer system.
This document is aimed at people who are implementing the Bedrock system from scratch. For people who are learning about or writing program for the Bedrock system, the memory device manual will generally be more useful.
Concepts
Pages
Memory is allocated as a contiguous array of pages. Each page is a 256 byte block of writeable memory. The initial value of each byte is zero.
At most 65535 pages can be allocated at a time. Pages are allocated and deallocated from the end of allocated memory, starting from address zero. The initial number of pages allocated is determined by the implementation.
Read-write head
A read-write head is a pointer used to access the allocated memory. Each head contains a 16 bit page offset and a 16 bit address offset. The initial value of each offset is zero. The memory address referenced by a head is calculated by multiplying the page offset by 256 and then adding the address offset.
This device contains two read-write heads: each head is controlled by one half of the device.
Ports
Port | Name | Description | Read | Write |
---|---|---|---|---|
0x10 |
Count | Number of pages allocated. | ✓ | ✓ |
0x11 |
grouped | grouped | ✓ | ✓ |
0x12 |
Page offset | Page offset for first head. | ✓ | ✓ |
0x13 |
grouped | grouped | ✓ | ✓ |
0x14 |
Address offset | Address offset for first head. | ✓ | ✓ |
0x15 |
grouped | grouped | ✓ | ✓ |
0x16 |
Head | Read and write with first head. | ✓ | ✓ |
0x17 |
aliased | aliased | ✓ | ✓ |
0x18 |
Copy | Copy one page to another. | ✗ | ✓ |
0x19 |
grouped | grouped | ✗ | ✓ |
0x1A |
Page offset | Page offset for second head. | ✓ | ✓ |
0x1B |
grouped | grouped | ✓ | ✓ |
0x1C |
Address offset | Address offset for second head. | ✓ | ✓ |
0x1D |
grouped | grouped | ✓ | ✓ |
0x1E |
Head | Read and write with second head. | ✓ | ✓ |
0x1F |
aliased | aliased | ✓ | ✓ |
Count
Reading from this port group will return the number of pages of allocated memory.
Writing to this port group will perform an atomic write, requesting on commit that the allocated page count be changed to the value written. Pages will be sequentially allocated or deallocated until the requested value is reached or until the implementation can no longer allocate or deallocate memory.
Page offset
Each page offset port group is associated with a read-write head.
Reading from one of these port groups will return the page offset of the associated head. Writing to one of these port groups will set the page offset of the associated head to the value written.
Address offset
Each address offset port group is associated with a read-write head.
Reading from one of these port groups will return the address offset of the associated head. Writing to one of these port groups will set the address offset of the associated head to the value written.
Head
Each head port is associated with a read-write head.
Reading from one of these ports will return the byte at the memory address referenced by that read-write head, and then will increment the address offset by 1, wrapping to zero on overflow. Reading from an unallocated memory address will return an undefined value.
Writing to one of these ports will write to the memory address referenced by that read-write head, and then will increment the address offset by 1, wrapping to zero on overflow. Writing to an unallocated memory address will cause undefined behaviour.
Copy
Writing to this port group will perform an atomic write, requesting on commit that a number of pages be copied equal to the value written. The initial source page is addressed by the page offset of the second read-write head. The initial destination page is addressed by the page offset of the first read-write head.
The contents of the source page will be copied to the destination page and then the source and destination pages will increment by 1, repeating until the requested number of pages have been copied. Copying to or from an unallocated page will cause undefined behaviour.
Wake behaviour
This device will never send a wake request to the system device.