1/*
2 * Copyright 2009 Jonas Sundström, jonas@kirilla.com
3 * Copyright 2007 François Revol, revol@free.fr
4 * Distributed under the terms of the MIT License.
5 *
6 * Copyright 2001, Travis Geiselbrecht. All rights reserved.
7 * Distributed under the terms of the NewOS License.
8 */
9
10
11#include <KernelExport.h>
12
13#include <arch_thread.h>
14#include <arch/cpu.h>
15#include <boot/kernel_args.h>
16#include <commpage.h>
17#include <elf.h>
18
19
20int arch_cpu_type;
21int arch_fpu_type;
22int arch_mmu_type;
23int arch_platform;
24
25status_t
26arch_cpu_preboot_init_percpu(kernel_args* args, int curr_cpu)
27{
28#warning IMPLEMENT arch_cpu_preboot_init_percpu
29
30	// The current thread must be NULL for all CPUs till we have threads.
31	// Some boot code relies on this.
32	arch_thread_set_current_thread(NULL);
33
34	return B_ERROR;
35}
36
37
38status_t
39arch_cpu_init_percpu(kernel_args* args, int curr_cpu)
40{
41#warning IMPLEMENT arch_cpu_init_percpu
42	//detect_cpu(curr_cpu);
43
44	// we only support one anyway...
45	return 0;
46}
47
48
49status_t
50arch_cpu_init(kernel_args* args)
51{
52#warning IMPLEMENT arch_cpu_init
53	arch_cpu_type = args->arch_args.cpu_type;
54	arch_fpu_type = args->arch_args.fpu_type;
55	arch_mmu_type = args->arch_args.mmu_type;
56	arch_platform = args->arch_args.platform;
57	arch_platform = args->arch_args.machine;
58
59	return B_ERROR;
60}
61
62
63status_t
64arch_cpu_init_post_vm(kernel_args* args)
65{
66#warning IMPLEMENT arch_cpu_init_post_vm
67	return B_ERROR;
68}
69
70
71status_t
72arch_cpu_init_post_modules(kernel_args* args)
73{
74#warning IMPLEMENT arch_cpu_init_post_modules
75	return B_ERROR;
76}
77
78
79void
80arch_cpu_sync_icache(void* address, size_t len)
81{
82#warning IMPLEMENT arch_cpu_sync_icache
83}
84
85
86void
87arch_cpu_memory_read_barrier(void)
88{
89#warning IMPLEMENT arch_cpu_memory_read_barrier
90	asm volatile ("nop;" : : : "memory");
91}
92
93
94void
95arch_cpu_memory_write_barrier(void)
96{
97#warning IMPLEMENT arch_cpu_memory_write_barrier
98	asm volatile ("nop;" : : : "memory");
99}
100
101
102void
103arch_cpu_invalidate_TLB_range(addr_t start, addr_t end)
104{
105#warning IMPLEMENT arch_cpu_invalidate_TLB_range
106}
107
108
109void
110arch_cpu_invalidate_TLB_list(addr_t pages[], int num_pages)
111{
112#warning IMPLEMENT arch_cpu_invalidate_TLB_list
113}
114
115
116void
117arch_cpu_global_TLB_invalidate(void)
118{
119#warning IMPLEMENT arch_cpu_global_TLB_invalidate
120}
121
122
123void
124arch_cpu_user_TLB_invalidate(void)
125{
126#warning IMPLEMENT arch_cpu_user_TLB_invalidate
127}
128
129
130status_t
131arch_cpu_user_memcpy(void* to, const void* from, size_t size,
132	addr_t* faultHandler)
133{
134#warning IMPLEMENT arch_cpu_user_memcpy
135	return B_BAD_ADDRESS;
136}
137
138
139ssize_t
140arch_cpu_user_strlcpy(char* to, const char* from, size_t size,
141	addr_t* faultHandler)
142{
143#warning IMPLEMENT arch_cpu_user_strlcpy
144	return B_BAD_ADDRESS;
145}
146
147
148status_t
149arch_cpu_user_memset(void* s, char c, size_t count, addr_t* faultHandler)
150{
151#warning IMPLEMENT arch_cpu_user_memset
152	return B_BAD_ADDRESS;
153}
154
155
156status_t
157arch_cpu_shutdown(bool reboot)
158{
159#warning IMPLEMENT arch_cpu_shutdown
160	return B_ERROR;
161}
162
163
164void
165arch_cpu_idle(void)
166{
167#warning IMPLEMENT arch_cpu_idle
168}
169
170// The purpose of this function is to trick the compiler. When setting the
171// page_handler to a label that is obviously (to the compiler) never used,
172// it may reorganize the control flow, so that the labeled part is optimized
173// away.
174// By invoking the function like this
175//
176//	if (mipsel_set_fault_handler(faultHandler, (addr_t)&&error))
177//		goto error;
178//
179// the compiler has to keep the labeled code, since it can't guess the return
180// value of this (non-inlinable) function. At least in my tests it worked that
181// way, and I hope it will continue to work like this in the future.
182//
183bool
184mipsel_set_fault_handler(addr_t *handlerLocation, addr_t handler)
185{
186// TODO: This doesn't work correctly with gcc 4 anymore!
187	*handlerLocation = handler;
188	return false;
189}
190
191