[RFC] Gcc and harvard architectures (towards AVR)
Svein E. Seldal
Svein.Seldal@solidas.com
Thu Dec 19 06:07:00 GMT 2002
Denis Chertykov wrote:
>>I have a technical suggestion for how to implement this, but I would
>>like to discuss the issue in a general basis before entering the
>>detailed discussion.
>
>
> Look to archive.
> Subject: Segment register support for the i386
> Date: 31 Dec 1999
Yes, I've seen this before. But it still is an unresolved issue IMHO.
For the avr-gcc this is a obvious limiation, as it required more
resources to do something that is simpler if gcc had the page support.
My suggestion is as follows:
A target has two address-spaces; the data (the default) and the code.
Consider the following example:
Accesses to the data-space is done as normal:
int a = 1234; // Declares a data storeage in data-space
int *p = &a; // Declare a pointer (in data-space) to a data-space
// storeage
x = *p; // Will fill x with 1234
Accesses using the code-space can be done as follows:
(Please note that code-space is usually read-only, and for this to work
you'd have to declare the variables and pointers as const - but I'll
skip this for now)
// Declare a datastoreage in code-space
int __attribute__((codespace)) b = 5678;
// Declare a pointer in data-space which points to a code-space
// address
int __attribute__((codespace)) * q = &b;
// Declare a pointer in code-space which points to a code-space
// address
int __attribute__((codespace)) * __attribute__((codespace)) r = &b;
// Will read the contents of the code-space datastorage 'b' and
// place it into x, which in this example is 5678
x = *q;
// This will fail because 'q' is a codespace pointer, while 'p' is
// dataspace pointer
q = p;
*) For those familiar with the avr target this is the same as the
'progmem' attribute. I just want to use the codespace name as a
demostration of how to do it.
Would this be a feasable implemenation of address-spaces?
What global (gcc) changes would a implementation like this imply?
Svein
More information about the Gcc
mailing list