source: mainline/kernel/arch/sparc64/src/sparc64.c@ 560b81c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 560b81c was 8b420fa, checked in by Jakub Jermar <jakub@…>, 10 years ago

Make explicitly sure the userspace window buffer is properly aligned

Do not rely on the implementation of kernel malloc() to assure this.
Instead, create a dedicated slab cache with the proper alignment for
its objects and allocate UWB's from there.

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[7510326]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>
[8b420fa]37#include <mm/slab.h>
38#include <config.h>
39#include <arch/proc/thread.h>
40#include <arch/trap/regwin.h>
41#include <debug.h>
[7510326]42
43#define SPARC64_ARCH_OP(op) ARCH_STRUCT_OP(sparc64_ops, op)
44
45static void sparc64_pre_mm_init(void);
46static void sparc64_post_mm_init(void);
47static void sparc64_post_cpu_init(void);
48static void sparc64_pre_smp_init(void);
49static void sparc64_post_smp_init(void);
50
51arch_ops_t sparc64_arch_ops = {
52 .pre_mm_init = sparc64_pre_mm_init,
53 .post_mm_init = sparc64_post_mm_init,
54 .post_cpu_init = sparc64_post_cpu_init,
55 .pre_smp_init = sparc64_pre_smp_init,
56 .post_smp_init = sparc64_post_smp_init,
57};
58
59arch_ops_t *arch_ops = &sparc64_arch_ops;
60
61void sparc64_pre_mm_init(void)
62{
63 SPARC64_ARCH_OP(pre_mm_init);
64}
65
66void sparc64_post_mm_init(void)
67{
68 SPARC64_ARCH_OP(post_mm_init);
[8b420fa]69
70 if (config.cpu_active == 1) {
71 STATIC_ASSERT(UWB_SIZE <= UWB_ALIGNMENT);
72 /* Create slab cache for the userspace window buffers */
73 uwb_cache = slab_cache_create("uwb_cache", UWB_SIZE,
74 UWB_ALIGNMENT, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
75 }
[7510326]76}
77
78void sparc64_post_cpu_init(void)
79{
80 SPARC64_ARCH_OP(post_cpu_init);
81}
82
83void sparc64_pre_smp_init(void)
84{
85 SPARC64_ARCH_OP(pre_smp_init);
86}
87
88void sparc64_post_smp_init(void)
89{
90 SPARC64_ARCH_OP(post_smp_init);
91}
92
93/** @}
94 */
Note: See TracBrowser for help on using the repository browser.