log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- Elsear brings super-fast Networking to Risc PC/A7000/A7000+ (News:)
- Latest hardware upgrade from RISCOSbits (News:)
- RISC OS London Show Report 2024 (News:1)
- Announcing the TIB 2024 Advent Calendar (News:1)
- Code GCC produces that makes you cry #12684 (Prog:39)
- RISCOSbits releases a new laptop solution (News:)
- Rougol November 2024 meeting on monday (News:)
- Drag'n'Drop 14i1 edition reviewed (News:)
- WROCC November 2024 talk o...ay - Andrew Rawnsley (ROD) (News:2)
- October 2024 News Summary (News:3)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
 
View on Mastodon
@www.iconbar.com@rss-parrot.net
Site Search
 
Article archives
Acorn Arcade forums: Programming: Some RISC OS memory questions
 
  Some RISC OS memory questions
  ksattic (19:05 21/7/2007)
  Phlamethrower (19:56 21/7/2007)
    ksattic (20:15 21/7/2007)
      Phlamethrower (20:30 21/7/2007)
 
Simon Wilson Message #103576, posted by ksattic at 19:05, 21/7/2007
ksattic
Finally, an avatar!

Posts: 1291
I have survived this long without an intimate knowledge of the RISC OS memory system, and now is the time for me to ask some questions. I looked online for answers for a few hours this morning, but couldn't find the answers I need.

PCI_RAMAlloc allocates RAM from a fixed, contiguous memory pool, and will return in R0 the logical address (for application access to memory locations) and in R1 the PCI address (physical address) for use by PCI bus masters (i.e. a TV card).

malloc, when called from an application, allocates RAM from the heap and is not guaranteed to be contiguous. The address returned for the start of memory is a logical address.

Questions:

1. How do I allocate a page of memory (4096 bytes)? I would like to avoid allocating 8191 bytes and aligning the start address to the 4096 byte boundary.

2. How do I find the physical and logical addresses of this memory?

3. How do I convert from a logical to a physical address?

4. If the logical and physical address on RISC OS is the same (I'm not sure if this is the case or not), then why does memory allocated with PCI_RAMAlloc have different logical and physical addresses?
  ^[ Log in to reply ]
 
Jeffrey Lee Message #103577, posted by Phlamethrower at 19:56, 21/7/2007, in reply to message #103576
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
1. How do I allocate a page of memory (4096 bytes)? I would like to avoid allocating 8191 bytes and aligning the start address to the 4096 byte boundary.
I think the correct way of allocating pages from the system is by creating a dynamic area, as they will (I believe) always start on page boundaries, and (I assume) will use contiguous pages where possible (and therefore contiguous hardware addresses)

Unless of course you're talking about allocating a page from an area of RAM which is already yours - in which case you'd need a memory manager that supports allocations at arbitraty alignments (or just allocate a larger buffer and round up the address).

2. How do I find the physical and logical addresses of this memory?

3. How do I convert from a logical to a physical address?
OS_ReadMemMapInfo, OS_ReadMemMapEntries, and OS_FindMemMapEntries.

Physical address = page number*page size.

4. If the logical and physical address on RISC OS is the same (I'm not sure if this is the case or not), then why does memory allocated with PCI_RAMAlloc have different logical and physical addresses?
The logical and physical addresses aren't the same.

Note that I don't have much experience with RISC OS's memory management either, so this is probably wrong in every single way tongue
  ^[ Log in to reply ]
 
Simon Wilson Message #103578, posted by ksattic at 20:15, 21/7/2007, in reply to message #103577
ksattic
Finally, an avatar!

Posts: 1291
OS_ReadMemMapInfo, OS_ReadMemMapEntries, and OS_FindMemMapEntries.

Physical address = page number*page size.
Excellent, this is exactly what I was thinking/hoping.

Note that I don't have much experience with RISC OS's memory management either, so this is probably wrong in every single way tongue
Cheers, but I think you are right.

By the way, what is the size of the PCI memory pool in RISC OS 5? I could probably get an estimate of this by allocating larger blocks until it fails.
  ^[ Log in to reply ]
 
Jeffrey Lee Message #103579, posted by Phlamethrower at 20:30, 21/7/2007, in reply to message #103578
PhlamethrowerHot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff

Posts: 15100
By the way, what is the size of the PCI memory pool in RISC OS 5? I could probably get an estimate of this by allocating larger blocks until it fails.
The pool which PCI_RAMAlloc uses? Looking at the task manager, there's a 'PCI shared memory' dynamic area, currently sitting at just over 1MB. But it can be dragged up to 32MB, so I suspect that's the maximum size wink You can probably determine this size programmatically (if a little unreliably) by using OS_DynamicArea - i.e. search for the area with the 'PCI shared memory' name and look at the size info.

If you're talking about the amount of logical address space allocated for PCI devices (i.e. the space which PCI_HardwareAddress gets logical addresses from) then I've got no idea what the maximum is. Presumably 1GB or more (RISC OS is limited to 2GB main RAM, right?)
  ^[ Log in to reply ]
 

Acorn Arcade forums: Programming: Some RISC OS memory questions