1/** \file
2 * \brief Miscellaneous kernel support code.
3 *
4 * This file contains miscellaneous architecture-independent kernel support
5 * code that doesn't belong anywhere else.
6 */
7
8/*
9 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
10 * All rights reserved.
11 *
12 * This file is distributed under the terms in the attached LICENSE file.
13 * If you do not find this file, copies can be found by writing to:
14 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
15 */
16
17#include <kernel.h>
18#include <stdarg.h>
19#include <stdio.h>
20#include <string.h>
21#include <inttypes.h>
22#include <barrelfish_kpi/cpu.h>
23#include <exec.h>
24#include <misc.h>
25#include <dispatch.h>
26#include <trace/trace.h>
27
28/**
29 * 'true' if kernel should handle and context switch on timer ticks.
30 * Pass the ticks parameter on the kernel command line if you
31 * want to change this.
32 */
33bool kernel_ticks_enabled = true;
34
35void
36wait_cycles(uint64_t duration)
37{
38    uint64_t last, elapsed;
39
40    printk(LOG_NOTE, "Waiting %" PRIu64 " cycles...\n", duration);
41
42    last = arch_get_cycle_count();
43    elapsed = 0;
44    while (elapsed < duration) {
45        uint64_t now = arch_get_cycle_count();
46        elapsed += (now - last);
47        last = now;
48    }
49}
50
51/**
52 * Stack protection handler
53 */
54void __stack_chk_fail(void); // Existence implied by (certainly configured) GCC.
55
56void __stack_chk_fail (void)
57{
58    panic("finally reached __stack_chk_fail()");
59}
60