1/** 2 * \file 3 * \brief Generic dispatcher struct shared between kernel and user 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, 2009, 2010, 2011, 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, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#ifndef BARRELFISH_KPI_DISPATCHER_SHARED_H 16#define BARRELFISH_KPI_DISPATCHER_SHARED_H 17 18#ifndef __ASSEMBLER__ 19 20#include <barrelfish_kpi/dispatcher_handle.h> 21 22#include <sys/cdefs.h> 23 24__BEGIN_DECLS 25 26#define DISP_NAME_LEN 16 27 28enum task_type { 29 TASK_TYPE_BEST_EFFORT, 30 TASK_TYPE_SOFT_REALTIME, 31 TASK_TYPE_HARD_REALTIME 32}; 33 34///< Architecture generic kernel/user shared dispatcher struct 35struct dispatcher_shared_generic { 36 uint32_t disabled; ///< Disabled flag (Must be able to change atomically) 37 uint32_t haswork; ///< Has work (ie. is runnable) (Must be able to change atomically) 38 39 lvaddr_t udisp; ///< User-mode pointer to dispatcher 40 uint32_t lmp_delivered, lmp_seen; ///< # LMP words delivered and seen 41 lvaddr_t lmp_hint; ///< Hint for location of LMP 42 lvaddr_t dispatcher_run; ///< Run entry 43 lvaddr_t dispatcher_lrpc; ///< LRPC entry 44 lvaddr_t dispatcher_pagefault; ///< Pagefault entry 45 lvaddr_t dispatcher_pagefault_disabled; ///< Disabled pagefault entry 46 lvaddr_t dispatcher_trap; ///< Trap entry 47 48 systime_t systime; ///< System time when last dispatched/resumed (W/O to kernel) 49 systime_t wakeup; ///< System time at which to wake dispatcher from sleep (R/O by kernel, on yield) 50 51 char name[DISP_NAME_LEN]; ///< Name of domain, for debugging purposes 52 53 uint64_t systime_frequency; ///< Systime frequency 54 coreid_t curr_core_id; ///< Core id of current core, in this part so kernel can update 55#ifdef __k1om__ 56 uint8_t xeon_phi_id; 57#endif 58}; 59 60static inline struct dispatcher_shared_generic* 61get_dispatcher_shared_generic(dispatcher_handle_t handle) 62{ 63 return (struct dispatcher_shared_generic*)handle; 64} 65 66static inline lvaddr_t get_dispatcher_vaddr(dispatcher_handle_t handle) 67{ 68 return (lvaddr_t)handle; 69} 70 71#include <stdio.h> 72static inline void dump_dispatcher(struct dispatcher_shared_generic *disp) 73{ 74 printf("Dump of dispatcher at address %p:\n", disp); 75 printf(" disabled = %d (%s)\n", disp->disabled, disp->disabled ? "RESUME" : "UPCALL" ); 76 printf(" haswork = %d\n", disp->haswork ); 77 printf(" udisp = 0x%" PRIxLVADDR "\n", disp->udisp ); 78 printf(" lmp_delivered = %d\n", disp->lmp_delivered ); 79 printf(" lmp_seen = %d\n", disp->lmp_seen ); 80 printf(" lpm_hint = 0x%" PRIxLVADDR "\n", disp->lmp_hint ); 81 printf(" dispatcher_run = 0x%" PRIxLVADDR "\n", disp->dispatcher_run ); 82 printf(" dispatcher_pagefault = 0x%" PRIxLVADDR "\n", disp->dispatcher_pagefault ); 83 printf(" dispatcher_pagefault_disabled = 0x%" PRIxLVADDR "\n", disp->dispatcher_pagefault_disabled ); 84 printf(" dispatcher_trap = 0x%" PRIxLVADDR "\n", disp->dispatcher_trap ); 85 printf(" systime = 0x%" PRIuSYSTIME "\n", disp->systime ); 86 printf(" wakeup = 0x%" PRIuSYSTIME "\n", disp->wakeup ); 87 printf(" name = %.*s\n", DISP_NAME_LEN, disp->name ); 88 printf(" curr_core_id = 0x%" PRIxCOREID "\n", disp->curr_core_id ); 89} 90 91__END_DECLS 92 93#endif //__ASSEMBLER__ 94#endif // BARRELFISH_KPI_DISPATCHER_SHARED_H 95