| 1 | #
|
|---|
| 2 | # Copyright (c) 2013 Jakub Klama
|
|---|
| 3 | # All rights reserved.
|
|---|
| 4 | #
|
|---|
| 5 | # Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | # modification, are permitted provided that the following conditions
|
|---|
| 7 | # are met:
|
|---|
| 8 | #
|
|---|
| 9 | # - Redistributions of source code must retain the above copyright
|
|---|
| 10 | # notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | # - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | # notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | # documentation and/or other materials provided with the distribution.
|
|---|
| 14 | # - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | # derived from this software without specific prior written permission.
|
|---|
| 16 | #
|
|---|
| 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | #
|
|---|
| 28 |
|
|---|
| 29 | #include <abi/asmtool.h>
|
|---|
| 30 |
|
|---|
| 31 | .text
|
|---|
| 32 |
|
|---|
| 33 | SYMBOL(kernel_image_start)
|
|---|
| 34 | # Install trap handlers
|
|---|
| 35 | set trap_table, %g1
|
|---|
| 36 | mov %g1, %tbr
|
|---|
| 37 |
|
|---|
| 38 | mov %psr, %g1 ! Initialize WIM
|
|---|
| 39 | add %g1, 1, %g2
|
|---|
| 40 | and %g2, 0x7, %g2
|
|---|
| 41 | set 1, %g3
|
|---|
| 42 | sll %g3, %g2, %g3
|
|---|
| 43 | mov %g3, %wim
|
|---|
| 44 |
|
|---|
| 45 | or %g1, 0x20, %g1
|
|---|
| 46 | or %g1, 0xf00, %g1 ! PIL
|
|---|
| 47 | wr %g1, %psr
|
|---|
| 48 |
|
|---|
| 49 | set boot_stack, %sp
|
|---|
| 50 | mov %sp, %fp
|
|---|
| 51 | sub %sp, 96, %sp
|
|---|
| 52 |
|
|---|
| 53 | mov %o1, %l1
|
|---|
| 54 | set 0xdeadbeef, %o0
|
|---|
| 55 | set 0xdeadbeef, %o1
|
|---|
| 56 | set 0, %o2
|
|---|
| 57 | call write_to_invalid
|
|---|
| 58 | nop
|
|---|
| 59 |
|
|---|
| 60 | mov %l1, %o1
|
|---|
| 61 | call arch_pre_main
|
|---|
| 62 | nop
|
|---|
| 63 |
|
|---|
| 64 | call main_bsp
|
|---|
| 65 | nop
|
|---|
| 66 |
|
|---|
| 67 | FUNCTION_BEGIN(early_putchar)
|
|---|
| 68 | set 0x80000100, %l0
|
|---|
| 69 | cmp %o0, '\n'
|
|---|
| 70 | bne skip
|
|---|
| 71 |
|
|---|
| 72 | set '\r', %l1
|
|---|
| 73 | sta %l1, [%l0] 0x1c
|
|---|
| 74 |
|
|---|
| 75 | skip:
|
|---|
| 76 | sta %o0, [%l0] 0x1c
|
|---|
| 77 | retl
|
|---|
| 78 | nop
|
|---|
| 79 | FUNCTION_END(early_putchar)
|
|---|
| 80 |
|
|---|
| 81 | SYMBOL(kernel_sp)
|
|---|
| 82 | .space 4
|
|---|
| 83 |
|
|---|
| 84 | SYMBOL(uspace_wbuf)
|
|---|
| 85 | .space 4
|
|---|
| 86 |
|
|---|
| 87 | .align 16
|
|---|
| 88 | .space 4096
|
|---|
| 89 | boot_stack:
|
|---|