Porting

From Arctic Core - the open source AUTOSAR embedded platform

Jump to: navigation, search

To make a new port two things have to be done.

  • Create the new architecture
  • Create a new board for the architecture

Contents

Create a new board

  1. Copy an suitable existing board from /boards
  2. The board_config.mk file contains a number of mandatory defines
    • Architecture:
      • ARCH - The architecture, e.g. mpc55xx
      • ARCH_FAM - The arhitecture family, e.g. ppc
      • ARCH_MCU - The MCU, e.g. mpc5554
    • Configuration
      • CFG - List of defines
    • Available modules/drivers
      • MOD_AVAIL - A list of available drivers/modules

How these are expanded see /scripts/rules.mk or Makesystem#Configuring

Create a new architecture

  • If it's a new architecture create the directory under /arch. If it's an variant to an existing one. #ifdef'ing the code should be enough. The architecture names should match the ones defines in /boards/<board>/board_config.mk file, i.e. arch/<ARCH_FAM>/<ARCH>.
  • Get a compiler for your arch.
    • Google and check if GCC exist for your ARCH
    • If you prefer commersial compilers Arctic Studio supports CodeWarrior and Windriver/Diab for PPC.

General

Guidelines:

  • Implement so that it's easy to maintain the code. There are a lot of room to tweak the performance using assembler all the way in the arch parts. The code now is made to be as common as possible for all arch's. Speed is not everything.

Files and interfaces

arch.c
  Arch specific part of the kernel. 
  API in arch.h (shared between arch.c and arch_krn.sx)

arch_krn.sx
  Assembler part of the kernel.
  API in arch.h (shared between arch.c and arch_krn.sx)

irq.c
 Implements the interrupt controller. Interface defined in irq.h

irq_types.h
 Add enum/defines for your interrupt vectors.

Mcu.c
  Apart from writing the standard function for fullfill the Autosar interface some Arctic Core specific functions also need be created.

sys_tick.c
  Defines the system tick timer.

stack.h/arch-stack.h
  Defines the different stack frames such as alignment and sizes. Includes the generated arch_offset.h.

asm_offset.c/arch_offset.c
  Used the the generate the different offsets into the stack frame (that are defined as c-structures).
  asm_offset/arch_offset.h is generated by the make-system.

Stacks

Usually there is an initial stack to setup the basic things. This can probably be the same as the interrupt stack. (Since interrupts are turned on just after the first task is swapped in).

os_sys.int_stack uses Os_CfgGetInterruptStackInfo() get info from the array os_interrupt_stack. The auto-genereated define for this is SYS_INT_STACK.


Interrupt execution order

In the text below interrupt==exception.

  1. HW takes the interrupt
  2. Software starts executing at some handler that do the following things
    • saving ALL registers
    • saves large context indicator
    • swaps to interrupt stack if at depth=0
    • calls IntCtrl_Entry() with a ptr to the just saved registers on the stack.
  3. IntCtrl() now determines if it is a Isr type 1 or type 2. If it is type 1 it just calls the function with interrupts disabled. If type 2 it calls Os_Isr() with the the stack and the pcb.
  4. Os_Isr() a lot of things.....
    • Calls the entry of the PCB
    • Calls IntCtrl_EOI()
    • Looks for new processes to swap in (if not at interrupt stack)
  5. Back to the handler restores context.

Ports

(--Mahi 13:54, 23 July 2009 (UTC)):

Known good versions
Family Port Compiler Status
PPC MPC5516 GCC/powerpc-eabi OK
PPC MPC5554 GCC/powerpc-eabispe OK
PPC MPC5567 GCC/powerpc-eabispe OK
PPC MPC5668 GCC/powerpc-eabispe OK
PPC MPC5606S CodeWarrior OK
ARM CORTEX-M3, STM32F107, STM32F103 STM10 GCC

Exception/Interrupt Tables

To fully support Autosar the following tables for each interrupt must be generated:

  • Irq_VectorTable
    • Used by interreupt controller and must be placed in a section of it's own.
    • The location should be controlled by the linker file.
    • The section name should be??
  • Irq_PriorityTable
    • Used to initialize the registers in the interrupt controller
    • Priority, uint8_t
    • const data.
    • It's usually a struct with index and priority.
  • Irq_IsrType
    • Used by the interrupt handler to determine if it should call a ISR1 or ISR2
    • Type1 or Type2 ISR
    • uint8_t IntCtrl_IsrType[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];

Since we are using dynamic allocation of the interrupt through the IntCtrl_AttachXXX calls we have Irq_VectorTable in RAM. This more than doubles the space occupied by the vector table.

Semi-dynamic:

  • The exception table is held in ROM using weak references.
    • PowerPC
      • The exception table is held in ROM.
      • IVOR4 exception is connected to INTC (The interrupt controller)
    • Cortex M3
      • The exception/interrupt table is held in ROM.
    • Common
      • Irq_VectorTable holds a PCB (Isr2) or a function entry (Isr1)

Static (NOT done in present release)

  • Irq_VectorTable (section ".isr_vectors") in ROM
  • We have 2 handlers, one Isr type 1 and one for Isr type 2.
  • Irq_IsrType is not needed.

ARM

Currenty supported:

  • arm cortex3

PowerPC

Currently supported:

  • mpc5516/mpc5517
  • mpc5554
  • mpc5567

Interrupts

Only Software vector mode is supported. Only the exception vectors have aligments requirements.

 
  
  .exc_vector
  (aligned)        code 
  ,-----,        ,-------------
 0|     |     /->| - Save registers
 1|     |    /   | - more more
 2|     |   /    |
 3|     |  /     |
 4|     | / |
 ....      IVOR4  
15|     |
  ´-----´


Stacks

Stack frames for big and small context
Large Small Address
Exception Frame (r3,r4,SRR0,SRR1,XER,etc) High address
VGPR (r0,r5-r12)
NVGPR (r14-r31) NVGPR (r14-r31)
Context (SP,LR,CR,context,backchain, padding) Context (SP,LR,CR,context,backchain, padding) Low Address

Normally you create the all the stacks at once and address them from the bottom (stack ptr below context), e.g context will have lower offsets than VGPR. However when the SPE is used the offsets (d and D in the mnemonics) are only 2^5 * 8 = 256.