/src/netbsd/src/sys/arch/arc/stand/boot/start.S

https://bitbucket.org/killerpenguinassassins/open_distrib_devel · Assembly · 122 lines · 36 code · 8 blank · 78 comment · 0 complexity · 7019395e4569e0488cd1f724e4f936da MD5 · raw file

  1. /* $NetBSD: start.S,v 1.5 2011/02/20 07:52:43 matt Exp $ */
  2. /*-
  3. * Copyright (c) 1999 The NetBSD Foundation, Inc.
  4. * All rights reserved.
  5. *
  6. * This code is derived from software contributed to The NetBSD Foundation
  7. * by Jonathan Stone, Michael Hitch and Simon Burge.
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  19. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  20. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  21. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  22. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  25. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  26. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  28. * POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /*
  31. * Copyright (c) 1992, 1993
  32. * The Regents of the University of California. All rights reserved.
  33. *
  34. * This code is derived from software contributed to Berkeley by
  35. * Ralph Campbell.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. * 1. Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * 2. Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in the
  44. * documentation and/or other materials provided with the distribution.
  45. * 3. Neither the name of the University nor the names of its contributors
  46. * may be used to endorse or promote products derived from this software
  47. * without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. * SUCH DAMAGE.
  60. *
  61. * @(#)start.s 8.2 (Berkeley) 1/21/94
  62. */
  63. /*
  64. * start.s -
  65. *
  66. * Contains code that is the first executed at boot time.
  67. *
  68. * Copyright (C) 1989 Digital Equipment Corporation.
  69. * Permission to use, copy, modify, and distribute this software and
  70. * its documentation for any purpose and without fee is hereby granted,
  71. * provided that the above copyright notice appears in all copies.
  72. * Digital Equipment Corporation makes no representations about the
  73. * suitability of this software for any purpose. It is provided "as is"
  74. * without express or implied warranty.
  75. *
  76. * from: Header: /sprite/src/boot/decprom/ds3100.md/RCS/start.s,
  77. * v 1.1 90/02/16 16:19:39 shirriff Exp SPRITE (DECWRL)
  78. */
  79. #include <mips/asm.h>
  80. #include <mips/cpuregs.h>
  81. #include "assym.h"
  82. .globl start
  83. start:
  84. .set noreorder
  85. #ifdef __GP_SUPPORT__
  86. la gp, _C_LABEL (_gp)
  87. #endif
  88. addi sp, -CALLFRAME_SIZ
  89. sw ra, CALLFRAME_RA(sp) # save ra
  90. sw a0, 0(sp) # save argc
  91. sw a1, 4(sp) # save argv
  92. sw a2, 8(sp) # save envp
  93. la v0, 0x80001000 # ARCBIOS_SPB
  94. lw v0, 8 * 4(v0) # FirmwareVector
  95. sw v0, _C_LABEL(ARCBIOS) # save ARCBIOS
  96. lw v0, 136(v0) # (*ARCBIOS->FlushAllCache)()
  97. jalr v0
  98. nop
  99. la a0, _C_LABEL (edata) # clear BSS
  100. move a1, zero
  101. la a2, _C_LABEL (end)
  102. jal _C_LABEL(memset) # memset(edata, 0, end - edata)
  103. subu a2, a2, a0
  104. lw a0, 0(sp) # restore argc
  105. lw a1, 4(sp) # restore argv
  106. jal _C_LABEL(main) # main(argc, argv, envp)
  107. lw a2, 8(sp) # restore envp
  108. lw ra, CALLFRAME_RA(sp) # restore RA
  109. j ra
  110. addi sp, CALLFRAME_SIZ
  111. .data
  112. .global ARCBIOS
  113. ARCBIOS:
  114. .data 0