vfs: check userland buffers before reading them.
[haiku.git] / src / system / kernel / arch / m68k / arch_040_cpu.cpp
blobcf18eb8bff72b4da8ac0ee91323bbdede0ad9405
1 /*
2 * Copyright 2003-2008, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * François Revol <revol@free.fr>
7 */
9 #include <KernelExport.h>
11 #include <arch_platform.h>
12 #include <arch_thread.h>
13 #include <arch/cpu.h>
14 #include <boot/kernel_args.h>
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 /* from arch_040_asm.S */
21 extern void flush_insn_pipeline_040(void);
22 extern void flush_atc_all_040(void);
23 extern void flush_atc_user_040(void);
24 extern void flush_atc_addr_040(addr_t addr);
26 #ifdef __cplusplus
28 #endif
32 #define CACHELINE 16
34 static void
35 sync_icache_040(addr_t address, size_t len)
37 int l, off;
38 char *p;
40 off = (unsigned int)address & (CACHELINE - 1);
41 len += off;
43 l = len;
44 p = (char *)address - off;
45 asm volatile ("nop");
47 #warning M68K: 040: use CPUSHP on pages when possible for speed.
48 do {
49 asm volatile ( \
50 "cpushl %%ic,(%0)\n" \
51 :: "a"(p));
52 p += CACHELINE;
53 } while ((l -= CACHELINE) > 0);
54 asm volatile ("nop");
58 static void
59 sync_dcache_040(addr_t address, size_t len)
61 int l, off;
62 char *p;
64 off = (unsigned int)address & (CACHELINE - 1);
65 len += off;
67 l = len;
68 p = (char *)address - off;
69 asm volatile ("nop");
71 #warning M68K: 040: use CPUSHP on pages when possible for speed.
72 do {
73 asm volatile ( \
74 "cpushl %%dc,(%0)\n" \
75 :: "a"(p));
76 p += CACHELINE;
77 } while ((l -= CACHELINE) > 0);
78 asm volatile ("nop");
82 struct m68k_cpu_ops cpu_ops_040 = {
83 &flush_insn_pipeline_040,
84 &flush_atc_all_040,
85 &flush_atc_user_040,
86 &flush_atc_addr_040,
87 &sync_dcache_040,
88 &sync_icache_040,
89 NULL // idle