os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/bootstrap/template.s
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
; Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
; All rights reserved.
sl@0
     3
; This component and the accompanying materials are made available
sl@0
     4
; under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
; which accompanies this distribution, and is available
sl@0
     6
; at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
;
sl@0
     8
; Initial Contributors:
sl@0
     9
; Nokia Corporation - initial contribution.
sl@0
    10
;
sl@0
    11
; Contributors:
sl@0
    12
;
sl@0
    13
; Description:
sl@0
    14
; template/bootstrap/template.s
sl@0
    15
; Template for platform specific boot code
sl@0
    16
;
sl@0
    17
sl@0
    18
		GBLL	__VARIANT_S__		; indicates that this is platform-specific code
sl@0
    19
		GBLL	__TEMPLATE_S__		; indicates which source file this is
sl@0
    20
sl@0
    21
		INCLUDE	bootcpu.inc
sl@0
    22
sl@0
    23
;
sl@0
    24
;*******************************************************************************
sl@0
    25
;
sl@0
    26
; Platform specific constant definitions
sl@0
    27
sl@0
    28
RamBank0Base		EQU		0x10000000
sl@0
    29
RamBank0MaxSize		EQU		0x00800000
sl@0
    30
RamBank1Base		EQU		0x20000000
sl@0
    31
RamBank1MaxSize		EQU		0x00000000
sl@0
    32
sl@0
    33
PrimaryRomBase		EQU		0x00000000
sl@0
    34
PrimaryRomSize		EQU		0x00800000
sl@0
    35
ExtensionRomBase	EQU		0x08000000
sl@0
    36
ExtensionRomSize	EQU		0x00000000
sl@0
    37
sl@0
    38
Serial0PhysBase		EQU		0x80000000
sl@0
    39
Serial1PhysBase		EQU		0x80000100
sl@0
    40
sl@0
    41
;
sl@0
    42
;*******************************************************************************
sl@0
    43
;
sl@0
    44
sl@0
    45
        AREA |Boot$$Code|, CODE, READONLY, ALIGN=6
sl@0
    46
sl@0
    47
;
sl@0
    48
;*******************************************************************************
sl@0
    49
;
sl@0
    50
sl@0
    51
sl@0
    52
sl@0
    53
sl@0
    54
;*******************************************************************************
sl@0
    55
; Initialise Hardware
sl@0
    56
;	Initialise CPU registers
sl@0
    57
;	Determine the hardware configuration
sl@0
    58
;	Determine the reset reason. If it is wakeup from a low power mode, perform
sl@0
    59
;		whatever reentry sequence is required and jump back to the kernel.
sl@0
    60
;	Set up the memory controller so that at least some RAM is available
sl@0
    61
;	Set R10 to point to the super page or to a temporary version of the super page
sl@0
    62
;		with at least the following fields valid:
sl@0
    63
;		iBootTable, iCodeBase, iActiveVariant, iCpuId
sl@0
    64
;	In debug builds initialise the debug serial port
sl@0
    65
;
sl@0
    66
; Enter with:
sl@0
    67
;	R12 points to TRomHeader
sl@0
    68
;	NO STACK
sl@0
    69
;	R14 = return address (as usual)
sl@0
    70
;
sl@0
    71
; All registers may be modified by this call
sl@0
    72
;*******************************************************************************
sl@0
    73
	IF	CFG_BootLoader
sl@0
    74
	; For bootloader we only get here on a full reset
sl@0
    75
	; Other resets will simply jump back into the previously-loaded image
sl@0
    76
	EXPORT	DoInitialiseHardware
sl@0
    77
DoInitialiseHardware	ROUT
sl@0
    78
	ELSE
sl@0
    79
	EXPORT	InitialiseHardware
sl@0
    80
InitialiseHardware	ROUT
sl@0
    81
	ENDIF
sl@0
    82
		MOV		r13, lr										; save return address
sl@0
    83
		ADRL	r1, ParameterTable							; pass address of parameter table
sl@0
    84
		BL		InitCpu										; initialise CPU/MMU registers
sl@0
    85
sl@0
    86
		; Put your hardware initialising code here
sl@0
    87
sl@0
    88
	IF	CFG_DebugBootRom
sl@0
    89
		BL		InitDebugPort
sl@0
    90
	ENDIF
sl@0
    91
sl@0
    92
; Set up the required super page values
sl@0
    93
		LDR		r10, =0xC0000000							; initial super page
sl@0
    94
		LDR		r0, =0x05040001								; variant code
sl@0
    95
		STR		r0, [r10, #SSuperPageBase_iActiveVariant]
sl@0
    96
		STR		r0, [r10, #SSuperPageBase_iHwStartupReason]	; reset reason (from hardware)
sl@0
    97
		ADD		r1, r10, #CpuPageOffset
sl@0
    98
		STR		r1, [r10, #SSuperPageBase_iMachineData]
sl@0
    99
		ADRL	r0, BootTable
sl@0
   100
		STR		r0, [r10, #SSuperPageBase_iBootTable]		; Set the boot function table
sl@0
   101
		STR		r12, [r10, #SSuperPageBase_iCodeBase]		; Set the base address of bootstrap code
sl@0
   102
		MRC		p15, 0, r0, c0, c0, 0						; read CPU ID from CP15 (remove if no CP15)
sl@0
   103
		STR		r0, [r10, #SSuperPageBase_iCpuId]
sl@0
   104
sl@0
   105
		MOV		pc, r13										; return
sl@0
   106
sl@0
   107
sl@0
   108
sl@0
   109
sl@0
   110
sl@0
   111
;*******************************************************************************
sl@0
   112
; Notify an unrecoverable error during the boot process
sl@0
   113
;
sl@0
   114
; Enter with:
sl@0
   115
;	R14 = address at which fault detected
sl@0
   116
;
sl@0
   117
; Don't return
sl@0
   118
;*******************************************************************************
sl@0
   119
	EXPORT	Fault
sl@0
   120
Fault	ROUT
sl@0
   121
		B		BasicFaultHandler	; generic handler dumps registers via debug
sl@0
   122
									; serial port
sl@0
   123
sl@0
   124
sl@0
   125
sl@0
   126
sl@0
   127
sl@0
   128
;*******************************************************************************
sl@0
   129
; Reboot the system
sl@0
   130
;
sl@0
   131
; Enter with:
sl@0
   132
;		R0 = reboot reason code
sl@0
   133
;
sl@0
   134
; Don't return (of course)
sl@0
   135
;*******************************************************************************
sl@0
   136
	ALIGN	32, 0
sl@0
   137
	EXPORT	RestartEntry
sl@0
   138
RestartEntry	ROUT
sl@0
   139
		; save R0 parameter in HW dependent register which is preserved over reset
sl@0
   140
		; put HW specific code here to reset system
sl@0
   141
		SUB		pc, pc, #8
sl@0
   142
sl@0
   143
sl@0
   144
sl@0
   145
sl@0
   146
sl@0
   147
;*******************************************************************************
sl@0
   148
; Get a pointer to the list of RAM banks
sl@0
   149
;
sl@0
   150
; The pointer returned should point to a list of {BASE; MAXSIZE;} pairs, where
sl@0
   151
; BASE is the physical base address of the bank and MAXSIZE is the maximum
sl@0
   152
; amount of RAM which may be present in that bank. MAXSIZE should be a power of
sl@0
   153
; 2 and BASE should be a multiple of MAXSIZE. The generic code will examine the
sl@0
   154
; specified range of addresses and determine the actual amount of RAM if any
sl@0
   155
; present in the bank. The list is terminated by an entry with zero size.
sl@0
   156
;
sl@0
   157
; The pointer returned will usually be to constant data, but could equally well
sl@0
   158
; point to RAM if dynamic determination of the list is required.
sl@0
   159
;
sl@0
   160
; Enter with :
sl@0
   161
;		R10 points to super page
sl@0
   162
;		R12 points to ROM header
sl@0
   163
;		R13 points to valid stack
sl@0
   164
;
sl@0
   165
; Leave with :
sl@0
   166
;		R0 = pointer
sl@0
   167
;		Nothing else modified
sl@0
   168
;*******************************************************************************
sl@0
   169
GetRamBanks	ROUT
sl@0
   170
		ADR		r0, %FT1
sl@0
   171
		MOV		pc, lr
sl@0
   172
1
sl@0
   173
		DCD		RamBank0Base, RamBank0MaxSize
sl@0
   174
		DCD		RamBank1Base, RamBank1MaxSize
sl@0
   175
		DCD		0,0				; terminator
sl@0
   176
sl@0
   177
sl@0
   178
sl@0
   179
sl@0
   180
sl@0
   181
;*******************************************************************************
sl@0
   182
; Get a pointer to the list of ROM banks
sl@0
   183
;
sl@0
   184
; The pointer returned should point to a list of entries of SRomBank structures,
sl@0
   185
; usually declared with the ROM_BANK macro.
sl@0
   186
; The list is terminated by a zero size entry (four zero words)
sl@0
   187
;
sl@0
   188
; ROM_BANK	PB, SIZE, LB, W, T, RS, SS
sl@0
   189
; PB = physical base address of bank
sl@0
   190
; SIZE = size of bank
sl@0
   191
; LB = linear base if override required - usually set this to 0
sl@0
   192
; W = bus width (ROM_WIDTH_8, ROM_WIDTH_16, ROM_WIDTH_32)
sl@0
   193
; T = type (see TRomType enum in kernboot.h)
sl@0
   194
; RS = random speed
sl@0
   195
; SS = sequential speed
sl@0
   196
;
sl@0
   197
; Only PB, SIZE, LB are used by the rest of the bootstrap.
sl@0
   198
; The information given here can be modified by the SetupRomBank call, if
sl@0
   199
; dynamic detection and sizing of ROMs is required.
sl@0
   200
;
sl@0
   201
; Enter with :
sl@0
   202
;		R10 points to super page
sl@0
   203
;		R12 points to ROM header
sl@0
   204
;		R13 points to valid stack
sl@0
   205
;
sl@0
   206
; Leave with :
sl@0
   207
;		R0 = pointer
sl@0
   208
;		Nothing else modified
sl@0
   209
;*******************************************************************************
sl@0
   210
GetRomBanks	ROUT
sl@0
   211
		ADR		r0, %FT1
sl@0
   212
		MOV		pc, lr
sl@0
   213
1
sl@0
   214
		ROM_BANK	PrimaryRomBase,		PrimaryRomSize,		0, ROM_WIDTH_32, ERomTypeXIPFlash, 0, 0
sl@0
   215
		ROM_BANK	ExtensionRomBase,	ExtensionRomSize,	0, ROM_WIDTH_32, ERomTypeXIPFlash, 0, 0
sl@0
   216
		DCD		0,0,0,0			; terminator
sl@0
   217
sl@0
   218
sl@0
   219
sl@0
   220
sl@0
   221
sl@0
   222
;*******************************************************************************
sl@0
   223
; Get a pointer to the list of hardware banks
sl@0
   224
;
sl@0
   225
; The pointer returned should point to a list of hardware banks declared with
sl@0
   226
; the HW_MAPPING and/or HW_MAPPING_EXT macros. A zero word terminates the list.
sl@0
   227
; For the direct memory model, all hardware on the system should be mapped here
sl@0
   228
; and the mapping will set linear address = physical address.
sl@0
   229
; For the moving or multiple model, only the hardware required to boot the kernel
sl@0
   230
; and do debug tracing needs to be mapped here. The linear addresses used will
sl@0
   231
; start at KPrimaryIOBase and step up as required with the order of banks in
sl@0
   232
; the list being maintained in the linear addresses used.
sl@0
   233
;
sl@0
   234
; HW_MAPPING PB, SIZE, MULT
sl@0
   235
;	This declares a block of I/O with physical base PB and address range SIZE
sl@0
   236
;	blocks each of which has a size determined by MULT. The page size used for
sl@0
   237
;	the mapping is determined by MULT. The linear address base of the mapping
sl@0
   238
;	will be the next free linear address rounded up to the size specified by
sl@0
   239
;	MULT.
sl@0
   240
;	The permissions used for the mapping are the standard I/O permissions (BTP_Hw).
sl@0
   241
;
sl@0
   242
; HW_MAPPING_EXT PB, SIZE, MULT
sl@0
   243
;	This declares a block of I/O with physical base PB and address range SIZE
sl@0
   244
;	blocks each of which has a size determined by MULT. The page size used for
sl@0
   245
;	the mapping is determined by MULT. The linear address base of the mapping
sl@0
   246
;	will be the next free linear address rounded up to the size specified by
sl@0
   247
;	MULT.
sl@0
   248
;	The permissions used for the mapping are determined by a BTP_ENTRY macro
sl@0
   249
;	immediately following this macro in the HW bank list or by a DCD directive
sl@0
   250
;	specifying a different standard permission type.
sl@0
   251
;
sl@0
   252
; HW_MAPPING_EXT2 PB, SIZE, MULT, LIN
sl@0
   253
;	This declares a block of I/O with physical base PB and address range SIZE
sl@0
   254
;	blocks each of which has a size determined by MULT. The page size used for
sl@0
   255
;	the mapping is determined by MULT. The linear address base of the mapping
sl@0
   256
;	is specified by the LIN parameter.
sl@0
   257
;	The permissions used for the mapping are the standard I/O permissions (BTP_Hw).
sl@0
   258
;
sl@0
   259
; HW_MAPPING_EXT3 PB, SIZE, MULT, LIN
sl@0
   260
;	This declares a block of I/O with physical base PB and address range SIZE
sl@0
   261
;	blocks each of which has a size determined by MULT. The page size used for
sl@0
   262
;	the mapping is determined by MULT. The linear address base of the mapping
sl@0
   263
;	is specified by the LIN parameter.
sl@0
   264
;	The permissions used for the mapping are determined by a BTP_ENTRY macro
sl@0
   265
;	immediately following this macro in the HW bank list or by a DCD directive
sl@0
   266
;	specifying a different standard permission type.
sl@0
   267
;
sl@0
   268
; Configurations without an MMU need not implement this function.
sl@0
   269
;
sl@0
   270
; Enter with :
sl@0
   271
;		R10 points to super page
sl@0
   272
;		R12 points to ROM header
sl@0
   273
;		R13 points to valid stack
sl@0
   274
;
sl@0
   275
; Leave with :
sl@0
   276
;		R0 = pointer
sl@0
   277
;		Nothing else modified
sl@0
   278
;*******************************************************************************
sl@0
   279
GetHwBanks	ROUT
sl@0
   280
		ADR		r0, %FT1
sl@0
   281
		MOV		pc, lr
sl@0
   282
1
sl@0
   283
	IF	CFG_MMDirect
sl@0
   284
		; for direct model we must map all peripherals here
sl@0
   285
		; use section mappings to reduce number of page tables required
sl@0
   286
		HW_MAPPING		0x00100000,	   31,	HW_MULT_1M		; 0x00100000 - 0x01FFFFFF
sl@0
   287
		HW_MAPPING		0x08000000,	   32,	HW_MULT_1M		; 0x08000000 - 0x09FFFFFF
sl@0
   288
		HW_MAPPING		0x80000000,		1,	HW_MULT_1M		; 0x80000000 - 0x800FFFFF
sl@0
   289
		HW_MAPPING		0x90000000,		1,	HW_MULT_1M		; 0x90000000 - 0x900FFFFF
sl@0
   290
		HW_MAPPING		0xA0000000,		1,	HW_MULT_1M		; 0xA0000000 - 0xA00FFFFF
sl@0
   291
		HW_MAPPING		0xB0000000,		1,	HW_MULT_1M		; 0xB0000000 - 0xB00FFFFF
sl@0
   292
		HW_MAPPING		0xB0100000,		1,	HW_MULT_1M		; 0xB0100000 - 0xB01FFFFF
sl@0
   293
	ELSE
sl@0
   294
		HW_MAPPING		0x80000000,		1,	HW_MULT_4K		; 0x80000000 - 0x80000FFF mapped at KPrimaryIOBase + 0
sl@0
   295
		HW_MAPPING		0x80010000,		1,	HW_MULT_4K		; 0x80010000 - 0x80010FFF mapped at KPrimaryIOBase + 0x1000
sl@0
   296
		HW_MAPPING		0x80020000,		1,	HW_MULT_64K		; 0x80020000 - 0x8002FFFF mapped at KPrimaryIOBase + 0x10000
sl@0
   297
		HW_MAPPING_EXT	0x90000000,		1,	HW_MULT_4K		; 0x90000000 - 0x90000FFF mapped at KPrimaryIOBase + 0x20000 ...
sl@0
   298
		DCD				BTP_Rom								; ... with same permissions as ROM
sl@0
   299
	ENDIF
sl@0
   300
		DCD			0											; terminator
sl@0
   301
sl@0
   302
sl@0
   303
sl@0
   304
sl@0
   305
sl@0
   306
;*******************************************************************************
sl@0
   307
; Set up RAM bank
sl@0
   308
;
sl@0
   309
; Do any additional RAM controller initialisation for each RAM bank which wasn't
sl@0
   310
; done by InitialiseHardware.
sl@0
   311
; Called twice for each RAM bank :-
sl@0
   312
;	First with R3 = 0xFFFFFFFF before bank has been probed
sl@0
   313
;	Then, if RAM is present, with R3 indicating validity of each byte lane, ie
sl@0
   314
;	R3 bit 0=1 if D0-7 are valid, bit1=1 if D8-15 are valid etc.
sl@0
   315
; For each call R1 specifies the bank physical base address.
sl@0
   316
;
sl@0
   317
; Enter with :
sl@0
   318
;		R10 points to super page
sl@0
   319
;		R12 points to ROM header
sl@0
   320
;		R13 points to stack
sl@0
   321
;		R1 = physical base address of bank
sl@0
   322
;		R3 = width (bottom 4 bits indicate validity of byte lanes)
sl@0
   323
;			 0xffffffff = preliminary initialise
sl@0
   324
;
sl@0
   325
; Leave with :
sl@0
   326
;		No registers modified
sl@0
   327
;*******************************************************************************
sl@0
   328
SetupRamBank	ROUT
sl@0
   329
		MOV		pc, lr
sl@0
   330
sl@0
   331
sl@0
   332
sl@0
   333
sl@0
   334
sl@0
   335
;*******************************************************************************
sl@0
   336
; Set up ROM bank
sl@0
   337
;
sl@0
   338
; Do any required autodetection and autosizing of ROMs and any additional memory
sl@0
   339
; controller initialisation for each ROM bank which wasn't done by
sl@0
   340
; InitialiseHardware.
sl@0
   341
;
sl@0
   342
; The first time this function is called R11=0 and R0 points to the list of
sl@0
   343
; ROM banks returned by the BTF_RomBanks call. This allows any preliminary setup
sl@0
   344
; before autodetection begins.
sl@0
   345
;
sl@0
   346
; This function is subsequently called once for each ROM bank with R11 pointing
sl@0
   347
; to the current information held about that ROM bank (SRomBank structure).
sl@0
   348
; The structure pointed to by R11 should be updated with the size and width
sl@0
   349
; determined. The size should be set to zero if there is no ROM present in the
sl@0
   350
; bank.
sl@0
   351
;
sl@0
   352
; Enter with :
sl@0
   353
;		R10 points to super page
sl@0
   354
;		R12 points to ROM header
sl@0
   355
;		R13 points to stack
sl@0
   356
;		R11 points to SRomBank info for this bank
sl@0
   357
;		R11 = 0 for preliminary initialise (all banks)
sl@0
   358
;
sl@0
   359
; Leave with :
sl@0
   360
;		Update SRomBank info with detected size/width
sl@0
   361
;		Set the size field to 0 if the ROM bank is absent
sl@0
   362
;		Can modify R0-R4 but not other registers
sl@0
   363
;
sl@0
   364
;*******************************************************************************
sl@0
   365
SetupRomBank	ROUT
sl@0
   366
		MOV		pc, lr
sl@0
   367
sl@0
   368
sl@0
   369
sl@0
   370
sl@0
   371
sl@0
   372
;*******************************************************************************
sl@0
   373
; Reserve physical memory
sl@0
   374
;
sl@0
   375
; Reserve any physical RAM needed for platform-specific purposes before the
sl@0
   376
; bootstrap begins allocating RAM for page tables/kernel data etc.
sl@0
   377
;
sl@0
   378
; There are two methods for this:
sl@0
   379
;	1.	The function ExciseRamArea may be used. This will remove a contiguous
sl@0
   380
;		region of physical RAM from the RAM bank list. That region will never
sl@0
   381
;		again be identified as RAM.
sl@0
   382
;	2.	A list of excluded physical address ranges may be written at [R11].
sl@0
   383
;		This should be a list of (base,size) pairs terminated by a (0,0) entry.
sl@0
   384
;		This RAM will still be identified as RAM by the kernel but will not
sl@0
   385
;		be allocated by the bootstrap and will subsequently be marked as
sl@0
   386
;		allocated by the kernel immediately after boot.
sl@0
   387
;
sl@0
   388
; Enter with :
sl@0
   389
;		R10 points to super page
sl@0
   390
;		R11 indicates where preallocated RAM list should be written.
sl@0
   391
;		R12 points to ROM header
sl@0
   392
;		R13 points to stack
sl@0
   393
;
sl@0
   394
; Leave with :
sl@0
   395
;		R0-R3 may be modified. Other registers should be preserved.
sl@0
   396
;*******************************************************************************
sl@0
   397
ReservePhysicalMemory	ROUT
sl@0
   398
		MOV		pc, lr
sl@0
   399
sl@0
   400
sl@0
   401
sl@0
   402
sl@0
   403
sl@0
   404
;*******************************************************************************
sl@0
   405
; Return parameter specified by R0 (see TBootParam enum)
sl@0
   406
;
sl@0
   407
; Enter with :
sl@0
   408
;		R0 = parameter number
sl@0
   409
;
sl@0
   410
; Leave with :
sl@0
   411
;		If parameter value is supplied, R0 = value and N flag clear
sl@0
   412
;		If parameter value is not supplied, N flag set. In this case the
sl@0
   413
;		parameter may be defaulted or the system may fault.
sl@0
   414
;		R0,R1,R2 modified. No other registers modified.
sl@0
   415
;
sl@0
   416
;*******************************************************************************
sl@0
   417
GetParameters ROUT
sl@0
   418
		ADR		r1, ParameterTable
sl@0
   419
		B		FindParameter
sl@0
   420
ParameterTable
sl@0
   421
		; Include any parameters specified in TBootParam enum here
sl@0
   422
		; if you want to override them.
sl@0
   423
		DCD		BPR_UncachedLin,	0			; parameter number, parameter value
sl@0
   424
	IF  :DEF: CFG_CPU_ARM1136 :LAND: (:LNOT: :DEF: CFG_CPU_ARM1136_ERRATUM_364296_FIXED)
sl@0
   425
        DCD     BPR_FinalMMUCRSet,      ExtraMMUCR + MMUCR_FI
sl@0
   426
        DCD     BPR_AuxCRSet,           DefaultAuxCRSet + 0x80000000
sl@0
   427
	ENDIF		
sl@0
   428
		DCD		-1								; terminator
sl@0
   429
sl@0
   430
sl@0
   431
sl@0
   432
sl@0
   433
sl@0
   434
;*******************************************************************************
sl@0
   435
; Do final platform-specific initialisation before booting the kernel
sl@0
   436
;
sl@0
   437
; Typical uses for this call would be:
sl@0
   438
;	1.	Mapping cache flushing areas
sl@0
   439
;	2.	Setting up pointers to routines in the bootstrap which are used by
sl@0
   440
;		the variant or drivers (eg idle code).
sl@0
   441
;
sl@0
   442
; Enter with :
sl@0
   443
;		R10 points to super page
sl@0
   444
;		R11 points to TRomImageHeader for the kernel
sl@0
   445
;		R12 points to ROM header
sl@0
   446
;		R13 points to stack
sl@0
   447
;
sl@0
   448
; Leave with :
sl@0
   449
;		R0-R9 may be modified. Other registers should be preserved.
sl@0
   450
;
sl@0
   451
;*******************************************************************************
sl@0
   452
FinalInitialise ROUT
sl@0
   453
		STMFD	sp!, {lr}
sl@0
   454
sl@0
   455
	IF	CFG_Template
sl@0
   456
sl@0
   457
		; set up main cache flush area
sl@0
   458
		MOV		r1, #0xE0000000			; physical address
sl@0
   459
	IF	CFG_MMDirect
sl@0
   460
		MOV		r0, r1					; direct, linear = physical
sl@0
   461
	ELSE
sl@0
   462
		LDR		r0, =KDCacheFlushArea	; linear
sl@0
   463
	ENDIF
sl@0
   464
		STR		r0, [r10, #SSuperPageBase_iDCacheFlushArea]
sl@0
   465
		MOV		r2, #BTP_MainCache		; permissions
sl@0
   466
		MOV		r3, #0x100000			; size
sl@0
   467
		MOV		r4, #20					; use section
sl@0
   468
		BL		MapContiguous
sl@0
   469
sl@0
   470
		; set up mini cache flush area
sl@0
   471
		ADD		r1, r1, r3				; physical address
sl@0
   472
		ADD		r0, r0, r3				; linear
sl@0
   473
		STR		r0, [r10, #SSuperPageBase_iAltDCacheFlushArea]
sl@0
   474
		MOV		r2, #BTP_MiniCache		; permissions
sl@0
   475
		BL		MapContiguous
sl@0
   476
sl@0
   477
		MOV		r3, #0x80000			; wrap for cache flush
sl@0
   478
		STR		r3, [r10, #SSuperPageBase_iDCacheFlushWrap]
sl@0
   479
		STR		r3, [r10, #SSuperPageBase_iAltDCacheFlushWrap]
sl@0
   480
sl@0
   481
		; set up idle code address
sl@0
   482
		ADR		r0, IdleCode
sl@0
   483
		ADD		r5, r10, #CpuPageOffset
sl@0
   484
		STR		r0, [r5, #CPUPage_Idle]
sl@0
   485
sl@0
   486
	ENDIF
sl@0
   487
sl@0
   488
		LDMFD	sp!, {pc}
sl@0
   489
sl@0
   490
sl@0
   491
sl@0
   492
sl@0
   493
sl@0
   494
;*******************************************************************************
sl@0
   495
; Output a character to the debug port
sl@0
   496
;
sl@0
   497
; Enter with :
sl@0
   498
;		R0 = character to output
sl@0
   499
;		R13 points to valid stack
sl@0
   500
;
sl@0
   501
; Leave with :
sl@0
   502
;		nothing modified
sl@0
   503
;*******************************************************************************
sl@0
   504
DoWriteC	ROUT
sl@0
   505
	IF	CFG_DebugBootRom
sl@0
   506
		STMFD	sp!, {r1,lr}
sl@0
   507
		BL		GetDebugPortBase
sl@0
   508
sl@0
   509
		; wait for debug port to be ready for data
sl@0
   510
		; output character to debug port
sl@0
   511
sl@0
   512
		LDMFD	sp!, {r1,pc}
sl@0
   513
	ELSE
sl@0
   514
		MOV		pc, lr
sl@0
   515
	ENDIF
sl@0
   516
sl@0
   517
	IF	CFG_DebugBootRom
sl@0
   518
sl@0
   519
;*******************************************************************************
sl@0
   520
; Initialise the debug port
sl@0
   521
;
sl@0
   522
; Enter with :
sl@0
   523
;		R12 points to ROM header
sl@0
   524
;		There is no valid stack
sl@0
   525
;
sl@0
   526
; Leave with :
sl@0
   527
;		R0-R2 modified
sl@0
   528
;		Other registers unmodified
sl@0
   529
;*******************************************************************************
sl@0
   530
InitDebugPort	ROUT
sl@0
   531
		MOV     r0, lr
sl@0
   532
		BL		GetDebugPortBase			; r1 = base address of debug port
sl@0
   533
sl@0
   534
		; set up debug port
sl@0
   535
sl@0
   536
		MOV		pc, r0
sl@0
   537
sl@0
   538
;*******************************************************************************
sl@0
   539
; Get the base address of the debug UART
sl@0
   540
;
sl@0
   541
; Enter with :
sl@0
   542
;		R12 points to ROM header
sl@0
   543
;		There may be no stack
sl@0
   544
;
sl@0
   545
; Leave with :
sl@0
   546
;		R1 = base address of port
sl@0
   547
;		No other registers modified
sl@0
   548
;*******************************************************************************
sl@0
   549
GetDebugPortBase	ROUT
sl@0
   550
		LDR		r1, [r12, #TRomHeader_iDebugPort]
sl@0
   551
		CMP		r1, #1
sl@0
   552
		BNE		%FA1							; skip if not port 1
sl@0
   553
		GET_ADDRESS	r1, Serial1PhysBase, Serial1LinBase
sl@0
   554
		MOV		pc, lr
sl@0
   555
1
sl@0
   556
		GET_ADDRESS	r1, Serial0PhysBase, Serial0LinBase
sl@0
   557
		MOV		pc, lr
sl@0
   558
sl@0
   559
	ENDIF	; CFG_DebugBootRom
sl@0
   560
sl@0
   561
sl@0
   562
sl@0
   563
sl@0
   564
sl@0
   565
;*******************************************************************************
sl@0
   566
; BOOT FUNCTION TABLE
sl@0
   567
;*******************************************************************************
sl@0
   568
sl@0
   569
BootTable
sl@0
   570
		DCD	DoWriteC				; output a debug character
sl@0
   571
		DCD	GetRamBanks				; get list of RAM banks
sl@0
   572
		DCD	SetupRamBank				; set up a RAM bank
sl@0
   573
		DCD	GetRomBanks				; get list of ROM banks
sl@0
   574
		DCD	SetupRomBank				; set up a ROM bank
sl@0
   575
		DCD	GetHwBanks				; get list of HW banks
sl@0
   576
		DCD	ReservePhysicalMemory			; reserve physical RAM if required
sl@0
   577
		DCD	GetParameters				; get platform dependent parameters
sl@0
   578
		DCD	FinalInitialise				; Final initialisation before booting the kernel
sl@0
   579
	IF :LNOT: CFG_MMUPresent				; no mmu, so use stub version ...
sl@0
   580
		DCD AllocatorStub				; allocate memory
sl@0
   581
	ELSE
sl@0
   582
		DCD HandleAllocRequest				; allocate memory		
sl@0
   583
		DCD	GetPdeValue				; usually in generic code
sl@0
   584
		DCD	GetPteValue				; usually in generic code
sl@0
   585
		DCD	PageTableUpdate				; usually in generic code
sl@0
   586
		DCD	EnableMmu				; Enable the MMU (usually in generic code)
sl@0
   587
	ENDIF
sl@0
   588
sl@0
   589
; These entries specify the standard MMU permissions for various areas
sl@0
   590
; They can be omitted if MMU is absent
sl@0
   591
	IF	CFG_MMUPresent
sl@0
   592
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RORO, MEMORY_FULLY_CACHED,       	1,  1,  0,  0   ; ROM
sl@0
   593
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RWNO, MEMORY_FULLY_CACHED,       	0,  1,  0,  0   ; kernel data/stack/heap
sl@0
   594
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RWNO, MEMORY_FULLY_CACHED,       	0,  1,  0,  0   ; super page/CPU page
sl@0
   595
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RWNO, MEMORY_FULLY_CACHED,  	0,  1,  0,  0   ; page directory/tables
sl@0
   596
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RONO, MEMORY_FULLY_CACHED,       	1,  1,  0,  0   ; exception vectors
sl@0
   597
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RWNO, MEMORY_STRONGLY_ORDERED,      0,  1,  0,  0   ; hardware registers
sl@0
   598
    DCD         0                                                           ; unused (minicache flush)
sl@0
   599
    DCD         0                                                           ; unused (maincache flush)
sl@0
   600
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RWNO, MEMORY_FULLY_CACHED,       	0,  1,  0,  0   ; page table info
sl@0
   601
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RWRW, MEMORY_FULLY_CACHED,       	1,  1,  0,  0   ; user RAM
sl@0
   602
    BTP_ENTRY   CLIENT_DOMAIN, PERM_RONO, MEMORY_STRONGLY_ORDERED,      1,  1,  0,  0   ; temporary identity mapping
sl@0
   603
    BTP_ENTRY   CLIENT_DOMAIN, UNC_PERM,  MEMORY_STRONGLY_ORDERED,      0,  1,  0,  0   ; uncached
sl@0
   604
	ENDIF
sl@0
   605
sl@0
   606
sl@0
   607
		END