Hi,
find below my CAR implementation for the Geode GX1 processor. Tested on my Geode GX1 system. Comments are welcome.
Juergen
/* * Copyright (C) 2007 Juergen Beisert juergen@kreuzholzen.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * This function pins the cache to a fixed address, to be used as an SRAM * until system memory is available. It will be done with the help of the * cache debug and test registers tr3, tr4 and tr5 * * Your hardware must fulfil these qualifications: * - support of the tr3, tr4 and tr5 registers * - size of one cache line must be 16 bytes * - your CAR area must be pinned to an address space where it * also would work in a regular way (do not pin it to an I/O space) * * Mapping of the cache happens from _sstage0_1 as startaddress up to * (_sstage0_1 + _car_size) as endaddress * * Note: This function uses some symbols created by the linker withing the * linker script file. This ensures future compatibility and keeps all layout * configuring into the linker script file. * * _sstage0_1: * contains the physical start address of the CAR area * _car_size: * size of the whole CAR area (in bytes) -> means cache size */ .code32 .section ".bright_side", "ax" .extern pre_c_stage .extern _sstage0_1 .extern _car_size
.globl CacheAsRam CacheAsRam: /* Save the BIST value */ movl %eax, %ebp
movl $_sstage0_1, %edi movl $_car_size, %ecx
next_cache_line: movl $0xdeadbeef, %eax /* value for each byte in the CAR */
/* Fill up cache fill buffer (one cache line = 16 bytes) */ xorl %ebx, %ebx /* entry 0 */ movl %ebx, %tr5 movl %eax, %tr3 /* value for entry 0 */
addl $0x04, %ebx /* entry 1 (at offset 4) */ movl %ebx, %tr5 movl %eax, %tr3 /* value for entry 1 */
addl $0x04, %ebx /* entry 2 (at offset 8) */ movl %ebx, %tr5 movl %eax, %tr3 /* value for entry 2 */
addl $0x04, %ebx /* entry 3 (at offset 12) */ movl %ebx, %tr5 movl %eax, %tr3 /* value for entry 3 */
/* pin this cache line to a fixed address */ movl %edi, %eax andl $0xFFFFF000, %eax /* upper 20 bit of the physical address */ orl $0x00000400, %eax /* mark this entry valid */ movl %eax, %tr4 /* setup correct cache set and cache line */ movl %edi, %eax andl $0x00000FF0, %eax /* calculate cache line from physical address bit [11:4] */ movl %edi, %ebx andl $0x00003000, %ebx /* calculate cache set from physical address bit [13:12] */ shrl $0xA, %ebx orl %ebx, %eax orl $0x01, %eax /* add write buffer command */ movl %eax, %tr5 /* do it */
/* loop until full cache is mapped */ addl $0x10, %edi subl $0x10, %ecx jnz next_cache_line
/* Restore the BIST value to %eax */ movl %ebp, %eax
/* prepare to run C code */ jmp pre_c_stage
On Sun, May 27, 2007 at 07:19:18PM +0200, Juergen Beisert wrote:
Hi,
find below my CAR implementation for the Geode GX1 processor. Tested on my Geode GX1 system. Comments are welcome.
Great, thanks!
Is this for v2 or v3 (or both?)
Can you please post a signed-off patch which puts this file in some directory + the surrounding code which is necessary to actually use it? I'm really eager to try it out on my ASI 5BLMP (== IGEL WinNET III)...
/*
Just a minor thing: The usual "This file is part of the LinuxBIOS project." line is missing here.
- Copyright (C) 2007 Juergen Beisert juergen@kreuzholzen.de
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
.globl CacheAsRam CacheAsRam:
Can we make this "cache_as_ram"? We should stick with the coding and naming guidelines as much as possible...
Otherwise the patch is nice and short, but I won't pretend I understand it ;) Haven't read the GX1 datasheets, yet...
Uwe.
Hi Uwe,
On Sunday 27 May 2007 22:59, Uwe Hermann wrote:
On Sun, May 27, 2007 at 07:19:18PM +0200, Juergen Beisert wrote:
Hi,
find below my CAR implementation for the Geode GX1 processor. Tested on my Geode GX1 system. Comments are welcome.
Great, thanks!
Is this for v2 or v3 (or both?)
Use it whereever you want. It only depends on the symbols "_sstage0_1" and "_car_size". But you can replace them with static values.
I used it in v2, but only to test it, if it works without a working SDRAM controller. I was not able to change the buildsystem to use it as a real CAR implementation (the v2 build system is to confusing and there are to many dependencies I can't control because I do not understand them).
Can you please post a signed-off patch which puts this file in some directory + the surrounding code which is necessary to actually use it? I'm really eager to try it out on my ASI 5BLMP (== IGEL WinNET III)...
It was intended for v3, but I can't provide you a patch because I changed the way to build it in arch/x86. And Ron don't like this way. So my patch would not help.
/*
Just a minor thing: The usual "This file is part of the LinuxBIOS project." line is missing here.
:-) Because it is currently not at part of the LinuxBIOS project.
Copyright (C) 2007 Juergen Beisert juergen@kreuzholzen.de
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.globl CacheAsRam
CacheAsRam:
Can we make this "cache_as_ram"? We should stick with the coding and naming guidelines as much as possible...
Its GPL. Do what you like to do.
Otherwise the patch is nice and short, but I won't pretend I understand it ;) Haven't read the GX1 datasheets, yet...
Its trivial: Read chapter "4.3.2.5 Cache Test Registers" - switch of cache - enable write back mode - fill the cache control data (as it does it by itself when it is enabled) - use it =8-)
Juergen
Juergen, I want to thank you for this fine work. I will incorporate it into V3.
I want to try to convince you that, even though you disagree with our decision on the v3 design, it is worth your time to go ahead and use a design that is not exactly what you wish to see.
I note this comment:
It was intended for v3, but I can't provide you a patch because I changed the way to build it in arch/x86. And Ron don't like this way. So my patch would not help.
You are, of course, free to do whatever you wish with V3; it's GPL. But bear in mind that V3 is a common effort, and that for each and every one of us, we can find some piece of V3 that we think ought to be done differently. A common effort involves compromise. We have a lot of contributors, and we can't afford a fork for each one. Many people, me included, have accepted different ideas on different areas of the code. No project of this type can succeed, absent this type of compromise.
In view of your talent and willingness to contribute code, I would hope that you could join us. I realize that the way we are doing the .S is not what you wish to see. I am hoping that you will join us anyway.
Thanks again for the CAR code!
ron