1/**
2 * \file
3 * \brief Startup prototypes.
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef __STARTUP_X86_H
16#define __STARTUP_X86_H
17
18#include <startup.h>
19#include <arch/x86/start_aps.h>
20
21#define BOOTINFO_BASE           ((lvaddr_t)0x200000)
22#define ARGS_BASE               (BOOTINFO_BASE + BOOTINFO_SIZE)
23#define DISPATCHER_BASE         (ARGS_BASE + ARGS_SIZE)
24#define MON_URPC_BASE           (DISPATCHER_BASE + DISPATCHER_SIZE)
25
26errval_t startup_map_init(lvaddr_t vbase, lpaddr_t base, size_t size,
27                          uint32_t flags);
28errval_t startup_alloc_init(void *state, genvaddr_t gvbase, size_t size,
29                            uint32_t flags, void **ret);
30void create_module_caps(struct spawn_state *st);
31void cleanup_bios_regions(char *mmap_addr, char **new_mmap_addr,
32                          uint32_t *new_mmap_length);
33
34struct dcb *spawn_bsp_init(const char *name);
35struct dcb *spawn_app_init(struct x86_core_data *core_data, const char *name);
36
37extern struct x86_core_data *glbl_core_data; // XXX: Arch specific
38
39// global pointers used in init_ap.S
40extern uint64_t x86_64_start_ap;
41extern uint64_t x86_64_init_ap_wait;
42extern uint64_t x86_32_start_ap;
43extern uint64_t x86_32_init_ap_wait;
44
45static inline void start_ap_signal(void)
46{
47
48    //pointer to a variable used as pseudo-lock to synchronize the BSP
49    //and the AP which gets enabled
50#if defined(__k1om__) || defined(__x86_64__)
51    volatile uint32_t *ap_wait = (volatile uint32_t *)
52        local_phys_to_mem((lpaddr_t)&x86_64_init_ap_wait - ((lpaddr_t)&x86_64_start_ap) +
53                          X86_64_REAL_MODE_LINEAR_OFFSET);
54#elif defined (__i386__)
55    volatile uint32_t *ap_wait = (volatile uint32_t *)
56        local_phys_to_mem((lpaddr_t)&x86_32_init_ap_wait - ((lpaddr_t)&x86_32_start_ap) +
57                          X86_32_REAL_MODE_LINEAR_OFFSET);
58#else
59#error "Architecture not supported"
60#endif
61
62    *ap_wait = AP_STARTED;
63}
64
65void configure_page_attribute_table(void);
66
67#endif // __STARTUP_X86_H
68