From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10764 invoked by alias); 4 Jun 2007 01:33:59 -0000 Received: (qmail 10756 invoked by uid 22791); 4 Jun 2007 01:33:58 -0000 X-Spam-Check-By: sourceware.org Received: from nz-out-0506.google.com (HELO nz-out-0506.google.com) (64.233.162.235) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 04 Jun 2007 01:33:56 +0000 Received: by nz-out-0506.google.com with SMTP id s1so734958nze for ; Sun, 03 Jun 2007 18:33:54 -0700 (PDT) Received: by 10.142.99.21 with SMTP id w21mr196845wfb.1180920834173; Sun, 03 Jun 2007 18:33:54 -0700 (PDT) Received: by 10.143.33.18 with HTTP; Sun, 3 Jun 2007 18:33:54 -0700 (PDT) Message-ID: <70d4f620706031833t47623014je3771e20b79c95c4@mail.gmail.com> Date: Mon, 04 Jun 2007 01:33:00 -0000 From: "Mike Sweeney" To: ecos-discuss@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: [ECOS] ARM architectural HAL questions (related to porting) X-SW-Source: 2007-06/txt/msg00045.txt.bz2 I am porting eCos to a new platform and XScale variant so I have some questions related to the ARM architectural HAL. I have a custom board and have NAND flash that I am going to burn my eCos image into. I have my own loader that copies the complete image from NAND flash into the image's load address in RAM. Since the RAM on my board is not located at 0x0, early in the eCos HAL startup code I am going to enable the MMU and locate RAM at 0x0(seems like PLATFORM_SETUP1 is the right place). My code will be linked to address 0x0 so the initial startup code will need to be position independent before the MMU kicks in. Hopefully this will help provide context in answering my questions below. My intended mode of startup seems to correspond to the RAM startup type but it doesn't seem to fit perfectly into this characterization based on the ARM architectural HAL implementation (vectors.S). 1) In vectors.S there is this code: // Come here to reset board warm_reset: #if defined(CYG_HAL_STARTUP_RAM) && \ !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) mrs r7,cpsr // move back to IRQ mode and r7,r7,#CPSR_MODE_BITS cmp r7,#CPSR_SUPERVISOR_MODE beq start #endif // We cannot access any LED registers until after PLATFORM_SETUP1 LED 7 mov r0,#0 // move vectors ldr r1,=__exception_handlers ldr r2,[r1,#0x08] // software interrupt str r2,[r0,#0x08] start: I don't understand what this code is doing. The comment says "move back to IRQ mode". If the processor is not in Supervisor mode then it does some stuff as you can see above, but I don't see how it is changing any mode here. What is the purpose of this code? 2) In this code from vectors.S: // Reset software interrupt pointer mov r0,#0 // move vectors ldr r1,.__exception_handlers #if defined(CYG_HAL_STARTUP_RAM) && \ !defined(CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS) cmp r7,#CPSR_SUPERVISOR_MODE beq 10f #endif ldr r2,[r1,#0x28] // software interrupt str r2,[r0,#0x28] 10: Why is the software interrupt vector only relocated if you are not in supervisor mode, similar to the code snippet posted in question 1 above? 3) In vectors.S there is then code to copy the vector table and fixed vectors to address 0x0. In my linker script couldn't I just link the ".vectors" section to address 0x0 and then there would be no need for "hal_vsr_table" in the fixed_vectors section? Basically my loader would copy my entire flash image into RAM at some load address and when I turn the MMU on .vectors would now be located at 0x0 without the need for a copy operation. It seems I can get by without doing what I suggest here and just using the default implementation in vectors.S here but I am more curious as to whether my approach is technically feasible. I know this is long but I appreciate any answers! -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss