1 | /*
|
---|
2 | * Copyright (c) 2016 Jakub Jermar
|
---|
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 | /** @addtogroup sparc64
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file
|
---|
33 | */
|
---|
34 |
|
---|
35 | #include <arch.h>
|
---|
36 | #include <arch/arch.h>
|
---|
37 | #include <mm/slab.h>
|
---|
38 | #include <sysinfo/sysinfo.h>
|
---|
39 | #include <config.h>
|
---|
40 | #include <arch/proc/thread.h>
|
---|
41 | #include <arch/trap/regwin.h>
|
---|
42 | #include <debug.h>
|
---|
43 |
|
---|
44 | #define SPARC64_ARCH_OP(op) ARCH_STRUCT_OP(sparc64_ops, op)
|
---|
45 |
|
---|
46 | static void sparc64_pre_mm_init(void);
|
---|
47 | static void sparc64_post_mm_init(void);
|
---|
48 | static void sparc64_post_cpu_init(void);
|
---|
49 | static void sparc64_pre_smp_init(void);
|
---|
50 | static void sparc64_post_smp_init(void);
|
---|
51 |
|
---|
52 | arch_ops_t sparc64_arch_ops = {
|
---|
53 | .pre_mm_init = sparc64_pre_mm_init,
|
---|
54 | .post_mm_init = sparc64_post_mm_init,
|
---|
55 | .post_cpu_init = sparc64_post_cpu_init,
|
---|
56 | .pre_smp_init = sparc64_pre_smp_init,
|
---|
57 | .post_smp_init = sparc64_post_smp_init,
|
---|
58 | };
|
---|
59 |
|
---|
60 | arch_ops_t *arch_ops = &sparc64_arch_ops;
|
---|
61 |
|
---|
62 | void sparc64_pre_mm_init(void)
|
---|
63 | {
|
---|
64 | SPARC64_ARCH_OP(pre_mm_init);
|
---|
65 | }
|
---|
66 |
|
---|
67 | void sparc64_post_mm_init(void)
|
---|
68 | {
|
---|
69 | SPARC64_ARCH_OP(post_mm_init);
|
---|
70 |
|
---|
71 | if (config.cpu_active == 1) {
|
---|
72 | static_assert(UWB_SIZE <= UWB_ALIGNMENT, "");
|
---|
73 | /* Create slab cache for the userspace window buffers */
|
---|
74 | uwb_cache = slab_cache_create("uwb_cache", UWB_SIZE,
|
---|
75 | UWB_ALIGNMENT, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
|
---|
76 |
|
---|
77 | /* Copy boot arguments */
|
---|
78 | ofw_tree_node_t *options = ofw_tree_lookup("/options");
|
---|
79 | if (options) {
|
---|
80 | ofw_tree_property_t *prop;
|
---|
81 |
|
---|
82 | prop = ofw_tree_getprop(options, "boot-args");
|
---|
83 | if (prop && prop->value) {
|
---|
84 | str_ncpy(bargs, CONFIG_BOOT_ARGUMENTS_BUFLEN,
|
---|
85 | prop->value, prop->size);
|
---|
86 | }
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | void sparc64_post_cpu_init(void)
|
---|
92 | {
|
---|
93 | SPARC64_ARCH_OP(post_cpu_init);
|
---|
94 | }
|
---|
95 |
|
---|
96 | void sparc64_pre_smp_init(void)
|
---|
97 | {
|
---|
98 | SPARC64_ARCH_OP(pre_smp_init);
|
---|
99 | }
|
---|
100 |
|
---|
101 | void sparc64_post_smp_init(void)
|
---|
102 | {
|
---|
103 | SPARC64_ARCH_OP(post_smp_init);
|
---|
104 | }
|
---|
105 |
|
---|
106 | /** @}
|
---|
107 | */
|
---|