newlib/libgloss/ms1/crt0-16-002.S
Aldy Hernandez 3f4df6211e * configure.in: Add ms1 case.
* configure: Regenerate.
	* ms1/16-002.ld: New.
	* ms1/16-003.ld: New.
	* ms1/64-001.ld: New.
	* ms1/access.c: New.
	* ms1/chmod.c: New.
	* ms1/close.c: New.
	* ms1/configure: New.
	* ms1/configure.in: New.
	* ms1/crt0-16-002.S: New.
	* ms1/crt0-16-003.S: New.
	* ms1/crt0-64-001.S: New.
	* ms1/crt0.S: New.
	* ms1/exit-16-002.c: New.
	* ms1/exit-16-003.c: New.
	* ms1/exit-64-001.c: New.
	* ms1/exit.c: New.
	* ms1/fstat.c: New.
	* ms1/getpid.c: New.
	* ms1/gettime.c: New.
	* ms1/isatty.c: New.
	* ms1/kill.c: New.
	* ms1/lseek.c: New.
	* ms1/Makefile.in: New.
	* ms1/open.c: New.
	* ms1/read.c: New.
	* ms1/sbrk.c: New.
	* ms1/startup-16-002.S: New.
	* ms1/startup-16-003.S: New.
	* ms1/startup-64-001.S: New.
	* ms1/stat.c: New.
	* ms1/time.c: New.
	* ms1/times.c: New.
	* ms1/trap.h: New.
	* ms1/trap.S: New.
	* ms1/unlink.c: New.
	* ms1/utime.c: New.
	* ms1/write.c: New.
2005-07-06 12:58:12 +00:00

112 lines
2.8 KiB
ArmAsm

; crt0_2.s - Startup code for the mrisc1. This code initializes the C
; run-time model.
;
; Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
;
; The authors hereby grant permission to use, copy, modify, distribute,
; and license this software and its documentation for any purpose, provided
; that existing copyright notices are retained in all copies and that this
; notice is included verbatim in any distributions. No written agreement,
; license, or royalty fee is required for any of the authorized uses.
; Modifications to this software may be copyrighted by their authors
; and need not follow the licensing terms described here, provided that
; the new terms are clearly indicated on the first page of each file where
; they apply.
;
; Create a label for the start of the eh_frame section.
.section .eh_frame
__eh_frame_begin:
.text
.global _start
_start:
;; Initialize the stack pointer
ldui sp, #%hi16(__stack)
addui sp, sp, #%lo16(__stack)
or fp, sp, sp
;; Zero the bss space
ldui r9, #%hi16(__bss_start)
addui r9, r9, #%lo16(__bss_start)
ldui r10, #%hi16(__bss_end)
addui r10, r10, #%lo16(__bss_end)
or r0, r0, r0
brle r10, r9, .Lnext1
or r0, r0, r0
.Lcpy0:
stw r0, r9, #0
addi r9, r9, #4
or r0, r0, r0 ; nop
brle r9, r10, .Lcpy0
or r0, r0, r0 ; nop
.Lnext1:
;; Copy data from ROM to Frame Buffer (on-chip memory)
ldui r9, #%hi16(_fbdata_start)
ori r9, r9, #%lo16(_fbdata_start)
ldui r10, #%hi16(_fbdata_end)
ori r10, r10, #%lo16(_fbdata_end)
ldui r11, #%hi16(_fbdata_vma)
brle r10, r9, .Lnext2
ori r11, r11, #%lo16(_fbdata_vma)
.Lcpy1:
ldw r5, r9, #$0
addi r9, r9, #$4
stw r5, r11, #$0
brlt r9, r10, .Lcpy1
addi r11, r11, #$4
.Lnext2:
;; Zero the frame buffer bss section
ldui r9, #%hi16(_fbbss_start)
ori r9, r9, #%lo16(_fbbss_start)
ldui r10, #%hi16(_fbbss_end)
ori r10, r10, #%lo16(_fbbss_end)
or r0, r0, r0
brle r10, r9, .Lnext3
or r0, r0, r0
.Lcpy2:
stw r0, r9, #$0
addi r9, r9, #$4
or r0, r0, r0
brle r9, r10, .Lcpy2
or r0, r0, r0
.Lnext3:
;; Call global and static constructors
ldui r10, #%hi16(_init)
ori r10, r10, #%lo16(_init)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop
;; Call main
ldui r10, #%hi16(main)
ori r10, r10, #%lo16(main)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop
;; DJK - Added 12Nov01. Pass main's return value to exit.
or r1, r11, r0
;; Jump to exit
ldui r10, #%hi16(exit)
ori r10, r10, #%lo16(exit)
or r0, r0, r0 ; nop
jal r14, r10
or r0, r0, r0 ; nop
;; Exit does not return, however, this code is to catch an
;; error if it does. Set the processor into sleep mode.
ori r1, r0, #$1
stw r1, r0, #%lo16(_DEBUG_HALT_REG)
or r0, r0, r0
or r0, r0, r0
or r0, r0, r0
or r0, r0, r0
or r0, r0, r0
.Lend:
jmp .Lend
or r0, r0, r0