Detecting RAM size, determining type of acia/uart
-
walter.preuninger
- Posts: 15
- Joined: 30 Apr 2018
Detecting RAM size, determining type of acia/uart
Happy Thanksgiving!
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
Thanks,
Walter
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
Thanks,
Walter
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Detecting RAM size, determining type of acia/uart
walter.preuninger wrote:
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Edit, to add: Musing on this, I can imagine a few possibilities for detecting mirroring. Here's one. Even without writing to the RAM, if you know what the possible chip sizes are, you could do something like read a stretch from one (without writing), and see if it matches what you read in another, like what's in $0200-03FF compared to what's in $2200-23FF or $0A00-0BFF. If it matches, it's the same RAM, mirrored into an additional address range. You would be able to figure out how many address bits are left out of the RAM select. (I left out ZP and page 1 since they're more likely to keep changing as the comparison program advances, and I'm sure you're not considering RAMs smaller than 1KB anyway.)
Quote:
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
I can't think of any way. Maybe someone else here has an idea.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: Detecting RAM size, determining type of acia/uart
walter.preuninger wrote:
Happy Thanksgiving!
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Quote:
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
Bill
Re: Detecting RAM size, determining type of acia/uart
To sum up the two seemingly conflicting answers above, in case it's confusing any newbies, the answer is that:
In the general case, no, you can't determine the memory size and peripheral hardware of a totally unknown system. Beyond the possibility of same memory locations being mapped to multiple addresses and the like, there may also be addresses that can put the system into a funny state if written, or even if read. (The Apple II, for example will hide the text screen and give you graphics screen instead if you read certain memory locations.)
However, given a specific known set of configurations, if they're designed well, you can often find a way to distinguish between them. E.g., on the Apple II one can certainly tell which RAM sockets are filled with RAM and how much is in each, and in many cases to figure out whether expansion boards are installed in certain slots.
In the general case, no, you can't determine the memory size and peripheral hardware of a totally unknown system. Beyond the possibility of same memory locations being mapped to multiple addresses and the like, there may also be addresses that can put the system into a funny state if written, or even if read. (The Apple II, for example will hide the text screen and give you graphics screen instead if you read certain memory locations.)
However, given a specific known set of configurations, if they're designed well, you can often find a way to distinguish between them. E.g., on the Apple II one can certainly tell which RAM sockets are filled with RAM and how much is in each, and in many cases to figure out whether expansion boards are installed in certain slots.
Curt J. Sampson - github.com/0cjs
-
walter.preuninger
- Posts: 15
- Joined: 30 Apr 2018
Re: Detecting RAM size, determining type of acia/uart
Quote:
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
Quote:
I can't think of any way. Maybe someone else here has an idea.
My newest memory map and decoding has a 16 byte hole, at $EF00-$EF0F. Brilliant!
Walter
Re: Detecting RAM size, determining type of acia/uart
Apple II had something called a Pascal 1.1 protocol for interface cards (IIe, IIgs) and built in ports (IIc, IIgs) in the firmware rom for identifying devices and rom addresses for built-in routines to access the device. The protocol was generally useful not just for pascal.
Cheers,
Andy
Cheers,
Andy
Re: Detecting RAM size, determining type of acia/uart
Generally, a RAM tester or detector will need to write and read back a couple of different values, to a couple of locations, at least. Being able to read back what you've written to a single address might only be sensing capacitance on the bus. (Edit: umm, maybe...)
Re: Detecting RAM size, determining type of acia/uart
BigEd wrote:
Generally, a RAM tester or detector will need to write and read back a couple of different values, to a couple of locations, at least. Being able to read back what you've written to a single address might only be sensing capacitance on the bus. (Edit: umm, maybe...)
This happened to me, with an Electron AP6:
https://stardot.org.uk/forums/viewtopic.php?f=3&t=13835
The schematic is in the first post of this thread:
https://stardot.org.uk/forums/viewtopic.php?f=3&t=6280
Dave
Re: Detecting RAM size, determining type of acia/uart
It is important to realise that a MPU or CPU running a simple memory test/check program may be mislead by a number of things and therefore may be unable to distinguish between real unique RAM locations and what appears to it as working RAM, but which is either not RAM or is RAM that has not been fully decoded (which is what Garth was talking about).
If you write a value and then within a short time period read a value from the same address, logic levels beyond a bus transceiver (the 74xxx245 that Dave talks about in the post above) may be maintained temporarily due to stray bus capacitance holding the voltage on each of the data lines. Thus to the simple program it looks like working RAM.
If the address decoding and the actual RAM chip(s) in use do not decode all the address lines, then certain address combinations will read the same RAM location at more than one address.
Some I/O chips / devices will echo the last written value back when read if there is no real readable register at that address.
Bank switching of memory and/or I/O devices can cause even more confusing results.
The result is that a program to detect all these possibilities would be rather complex.
In the real world, most RAM testing programs are designed with specific hardware memory maps in mind. This reduces the complexity because you are then limiting the number of possibilities.
For more, search the internet for ‘RAM testing techniques’ or for ‘test algorithms for RAM’.
For I/O chips, again, a program to try to identify the large number of different I/O chips / devices would be rather complex. If you narrow the field to a small number of different I/O chips / devices, then by studying the datasheet for each chip/device, it should be possible to write a program to at least workout what is not connected, and hence narrow down what is fitted.
However, this does make the assumption that the I/O chips / devices are wired with their register select / address lines in the conventional manner (MPU/CPU A0 to I/O chip’s A0 or equivalent) and that they are fully address decoded.
Not all designs fully decode the addresses, hence a single I/O chip or device can appear in the memory map multiple times. And sometimes the register select / address lines are not wired up as you would expect. Either of these makes the task very much harder.
Mark
If you write a value and then within a short time period read a value from the same address, logic levels beyond a bus transceiver (the 74xxx245 that Dave talks about in the post above) may be maintained temporarily due to stray bus capacitance holding the voltage on each of the data lines. Thus to the simple program it looks like working RAM.
If the address decoding and the actual RAM chip(s) in use do not decode all the address lines, then certain address combinations will read the same RAM location at more than one address.
Some I/O chips / devices will echo the last written value back when read if there is no real readable register at that address.
Bank switching of memory and/or I/O devices can cause even more confusing results.
The result is that a program to detect all these possibilities would be rather complex.
In the real world, most RAM testing programs are designed with specific hardware memory maps in mind. This reduces the complexity because you are then limiting the number of possibilities.
For more, search the internet for ‘RAM testing techniques’ or for ‘test algorithms for RAM’.
For I/O chips, again, a program to try to identify the large number of different I/O chips / devices would be rather complex. If you narrow the field to a small number of different I/O chips / devices, then by studying the datasheet for each chip/device, it should be possible to write a program to at least workout what is not connected, and hence narrow down what is fitted.
However, this does make the assumption that the I/O chips / devices are wired with their register select / address lines in the conventional manner (MPU/CPU A0 to I/O chip’s A0 or equivalent) and that they are fully address decoded.
Not all designs fully decode the addresses, hence a single I/O chip or device can appear in the memory map multiple times. And sometimes the register select / address lines are not wired up as you would expect. Either of these makes the task very much harder.
Mark
- BigDumbDinosaur
- Posts: 9426
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Detecting RAM size, determining type of acia/uart
walter.preuninger wrote:
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Quote:
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
In the case of a home-brew machine, the designer knows what is or isn't present, and what could be present, because s/he designed the circuit that way. I use NXP UARTs in my designs, and place them into the mempry map at specific places. So it's relatively easy to determine if a UART is present or absent at a particular address—test writes to certain register locations, followed by a significant delay, followed by reads of those locations make the determination. It works because of my choice of UART, not due to clever programming.
With plug-in cards, it gets more involved. Most plug-in cards for PC hardware have some ROM for boot code and the PC's BIOS has hooks that look for "option ROMs" during POST. If an option ROM is found some code is executed in it that among other things, tells the system about the hardware on the card. You can do the same thing in a 65C02/65C816 system if you are willing to add the necessary complexity.
Speaking of the 65C816, as it can address more than 64KB, an interesting "mirroring" problem arises that wouldn't affect the 65C02: "phantom" banks. In a system in which, say, only bits 0-3 of the bank are demultiplexed (demuxed), a blind write/read to an extended address can't conclusively determine if the address actually exists. In such a case, only extended address bits A16-A19 are being generated. Hence a bank bit pattern of %yyyyxxxx looks exactly the same as %0000xxxx, where yyyy is any non-zero pattern. yyyy would correspond to A20-A23 if the bank were fully demuxed.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Detecting RAM size, determining type of acia/uart
hoglet wrote:
Indeed, if the RAM is buffered...
Re: Detecting RAM size, determining type of acia/uart
walter.preuninger wrote:
Happy Thanksgiving!
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
Thanks,
Walter
Is it safe to determine the size of RAM by writing a value to a location, reading it back and if they are the same, you have a RAM address?
Is it possible to programmatically determine which chip you have, such as a 6551,8250, 16450, 16550 etc?
Thanks,
Walter
In my first reply I assumed you had some idea about the architecture of the system, or had control over the architecture of the system, and that you were mostly interested in getting the BIOS to adapt to configuration changes. It seems others are not making that assumption and treating your questions as general and academic.
The identity of each of UARTs you gave in your list could certainly be determined with software, but not all possible peripherals could be, and if you have no idea what the architecture of your system is, then determining RAM size by writing then reading memory most likely would be just a shot in the dark. You would be better off taking a peek under the cover and seeing what RAM it had installed.
So, perhaps you could let us know your goals here?
Last edited by BillO on Sat Nov 30, 2019 10:45 pm, edited 1 time in total.
Bill
Re: Detecting RAM size, determining type of acia/uart
BigEd wrote:
Generally, a RAM tester or detector will need to write and read back a couple of different values, to a couple of locations, at least. Being able to read back what you've written to a single address might only be sensing capacitance on the bus. (Edit: umm, maybe...)
Bill
-
walter.preuninger
- Posts: 15
- Joined: 30 Apr 2018
Re: Detecting RAM size, determining type of acia/uart
Quote:
Perhaps we should be asking what your goals are.
My eyes were way bigger than my skills. I will start with a simple system, and add features after I can get a design running.
But thanks for all the great responses.
Walter
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: Detecting RAM size, determining type of acia/uart
Just randomly musing here ...
If you assume 64K max and contiguous RAM from $0000 to $xxFF then you could write the complement of the page number to a single hopefully innocuous byte in each page in descending order first (e.g. $00 to $FF5A, $01 to $FE5A, $02 to $FD5A ... $FF to $005A) then perform an ascending page search from $005A up to $xx5A until you encountered a value that didn't match what was expected. This plan might still choke on memory-mapped I/O and <256-byte decode granularity, but it should avoid being fooled by mirrored RAM, if I'm not mistaken.
Testing each byte of RAM might be accomplished by filling descending addresses with the XOR of the high half and low half of each alleged address, then reversing direction to see if and when the pattern breaks?
If you assume 64K max and contiguous RAM from $0000 to $xxFF then you could write the complement of the page number to a single hopefully innocuous byte in each page in descending order first (e.g. $00 to $FF5A, $01 to $FE5A, $02 to $FD5A ... $FF to $005A) then perform an ascending page search from $005A up to $xx5A until you encountered a value that didn't match what was expected. This plan might still choke on memory-mapped I/O and <256-byte decode granularity, but it should avoid being fooled by mirrored RAM, if I'm not mistaken.
Testing each byte of RAM might be accomplished by filling descending addresses with the XOR of the high half and low half of each alleged address, then reversing direction to see if and when the pattern breaks?
Got a kilobyte lying fallow in your 65xx's memory map? Sprinkle some VTL02C on it and see how it grows on you!
Mike B. (about me) (learning how to github)
Mike B. (about me) (learning how to github)