![]() |
![]() |
#1 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Allocating 0xC00000 memory
So my current project requires the "gold standard" 1mb of ram. In the trackloaded/system unfriendly version I use AllocMem to work out where any additional ram might be before I take over the system.
The problem is, on a KS1.3 machine the returned address will be something like 0xC04AD0. I am guessing this is due to the OS using the ram at 0xC00000 for itself? Is it safe to convert that number (or things in a similar range) to 0xC00000 so I can use the full 512kb ? I think in any other ram configuration I should probably be safe with the returned address as it will likely be > 512kb ? |
![]() |
![]() |
#2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Why not just checking Exec's MemList for the largest available block (either chip or fast) during boot?
|
![]() |
![]() |
#3 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
![]() |
|
![]() |
![]() |
#4 | |
Going nowhere
Join Date: Oct 2001
Location: United Kingdom
Age: 50
Posts: 9,017
|
Quote:
As youve worked out, execbase offsets and pointers are located in that memory space at the start of $c00000, once you know you are finished with interrogating system resources, disable all interrupts and use $c00000 as your base address and use it all up. |
|
![]() |
![]() |
#5 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
Also how low can I go with chip ram? The size of the vector table? 256? |
|
![]() |
![]() |
#6 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,573
|
Also make sure you don't accidentally overwrite supervisor stack (which is usually located at the end of $c00000 RAM if system does not have any real fast RAM), or move it to better place.
Quote:
![]() |
|
![]() |
![]() |
#7 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
even $0 if you make some slalom between vectors
![]() EDIT: ops.. Toni first ![]() |
![]() |
![]() |
#8 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
Yeah, I have the supervisor stack under control. It’s not such a big deal as it doesn’t grow too big. |
|
![]() |
![]() |
#9 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
However, do not assume that the memory is at $c00000.
Like suggested make use of Exec before destroying it ![]() My discoverer of 512KB mem chunks: Code:
_LVOSuperState EQU -150 ;A6=ExecBase lea $somewhere_in_low_mem,a1 movea.l a1,a2 clr.l -(a1) ;two chunks clr.l -(a1) ;but you can use as many as you want moveq #8,d1 swap d1 ;#$80000 lea $142(a6),a0 ;a0=ExecBase->MemList _ml1 movea.l (a0),a0 ;a0=next Node move.l $18(a0),d0 ;mh_Upper add.l #$ffff,d0 ;skip over possible SSP clr.w d0 ;pad to real chunk Upper move.l $14(a0),d2 ;mh_Lower clr.w d2 ;pad to real chunk Lower _ml2 sub.l d1,d0 ;512KiB from Mem chunk ble.b _mlex ;<=0? end of list (first 512 KiB chip RAM) cmp.l d2,d0 ;check end of Node blo.b _ml1 ;next Node move.l d0,(a1)+ ;fill my 512KiB blocks memlist cmpa.l a1,a2 ;enough? bne.b _ml2 ;else more _mlex jmp _LVOSuperState(a6) |
![]() |
![]() |
#10 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
I currently use AvailMem asking for the largest fast ram available, then allocate it to get the location. Note this happens only on boot (track loaded program). For this to work my assumption must hold that the largest available ram will be either: (1) 512kb at $C00000 -or- (2) >512kb somewhere else Is it possible to have a 512kb expansion somewhere other than $C00000 ? |
|
![]() |
![]() |
#11 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 54
Posts: 4,491
|
Quote:
On 24 bit machine (A1000/500/600/2000) you can have memory from $200000 to $A00000 or also from $c00000 to $D80000. On 32 bit machine also from $01000000 to .. $80000000 ![]() EDIT:in any case normally on the A500 in the trap door is at $c00000 ![]() |
|
![]() |
![]() |
#12 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
Guess I will need to find a more robust way to find that start address. |
|
![]() |
![]() |
#13 | |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,642
|
Quote:
![]() |
|
![]() |
![]() |
#14 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
I mean, this code seems to work fine, it's just that I am now almost running out of slow/fast ram for the first time ever, so really trying to make sure I get access to every last byte available. |
|
![]() |
![]() |
#15 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Don't assume any fixed memory locations at all! Properly detect the available memory and use that info for your memory consumption. Align the memory pointer if necessary but please do not assume any fixed memory locations at all.
|
![]() |
![]() |
#16 |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
No, I don’t assume the location, I was just only aligning at c00xxxx. Looks like this was a bad assumption and I might also need to check for <512kb allocations elsewhere and also align those.
|
![]() |
![]() |
#17 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
Quote:
Otherwise, there is a little known feature of vlink, which I used in all of my games to output relocation tables: you have to use the "rawseg" output format and define segments with a linker script (e.g. a "chip" and a "fast" segment). The linker will output a raw binary file for each segment, so you can load "chip" and "fast" binaries into different locations. Additionally, when specifying the -q (emit relocs) option, it writes a relocation tables for all segment combinations (usually only fast-fast and fast-chip). These tables are simple to process for your loader: first longword is number of entries, followed by all the relocation offsets. Example linker script from my latest game, which defines those two segments, and assigns the sections CODE, DATA, BSS and __MERGED (small data) to "fast" and chipmem to "chip". The base addresses, 0x400 and 0x1000000, are ignored. Code:
PHDRS { fast PT_LOAD; chip PT_LOAD; } SECTIONS { . = 0x400; .chip: { *(chipmem) . = ALIGN(2); _FREECHIP = .; } :chip . = 0x100000; .text: { _START = .; *(CODE) } :fast .data: { *(DATA) } .sdata: { _LinkerDB = . + 0x7ffe; _SDA_BASE_ = . + 0x7ffe; *(.sdata __MERGED) } .bss: { *(BSS) } } |
|
![]() |
![]() |
#18 | |
Registered User
Join Date: Mar 2016
Location: Australia
Posts: 882
|
Quote:
I am pretty sure you helped me get it all working via email last year ![]() |
|
![]() |
![]() |
#19 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,545
|
LOL. Sorry, I forgot.
![]() But when it was a private email, then maybe others feel inspired now. |
![]() |
![]() |
#20 |
Registered User
Join Date: May 2013
Location: Grimstad / Norway
Posts: 853
|
And it could also be that chipram is 1M or 2M so don't fall over if you don't find another chunk.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmiDEVcpp: Allocating gfxdata in chip mem | tolkien | Coders. C/C++ | 9 | 22 April 2013 20:21 |
Listing files, loading files and allocating all available chip ram. | h0ffman | Coders. System | 16 | 04 April 2013 21:24 |
Problem allocating some memory | CmdrVimes | Coders. General | 4 | 03 September 2010 23:23 |
Allocating Fast RAM as Chip? | Fingerlickin_B | support.Hardware | 22 | 20 November 2008 22:15 |
A600 Not allocating full 1mb | FOL | support.Hardware | 24 | 18 October 2008 13:02 |
|
|