define dispatcher_size 10;
/* Size of (x86_64) VNode: */
define vnode_size 12; /* BASE_PAGE_BITS */
+/* size of a kernel control block */
+define kcb_size 12;
/**
The capabilities of the whole system are listed thereafter.
cap PerfMon is_always_copy {
};
+
+/** KernelControlBlock represents a struct kcb which contains all the pointers
+ * to core-local global state of the kernel.
+ **/
+
+cap KernelControlBlock from RAM {
+ "struct kcb" kcb;
+
+ address { mem_to_phys(kcb) };
+ /* base page size for now so we can map the kcb in boot driver */
+ size_bits { kcb_size };
+};
// Size of dispatcher
#define OBJBITS_DISPATCHER 10
+// Size of kernel control block
+#define OBJBITS_KCB 12
+
#ifndef __ASSEMBLER__
#define CAPRIGHTS_READ (1 << 0)
static inline bool type_is_vnode(enum objtype type)
{
- STATIC_ASSERT(25 == ObjType_Num, "Check VNode definitions");
+ STATIC_ASSERT(26 == ObjType_Num, "Check VNode definitions");
return (type == ObjType_VNode_x86_64_pml4 ||
type == ObjType_VNode_x86_64_pdpt ||
static inline size_t vnode_objbits(enum objtype type)
{
// This function should be emitted by hamlet or somesuch.
- STATIC_ASSERT(25 == ObjType_Num, "Check VNode definitions");
+ STATIC_ASSERT(26 == ObjType_Num, "Check VNode definitions");
if (type == ObjType_VNode_x86_64_pml4 ||
type == ObjType_VNode_x86_64_pdpt ||
*/
static inline size_t vnode_entry_bits(enum objtype type) {
// This function should be emitted by hamlet or somesuch.
- STATIC_ASSERT(25 == ObjType_Num, "Check VNode definitions");
+ STATIC_ASSERT(26 == ObjType_Num, "Check VNode definitions");
if (type == ObjType_VNode_x86_64_pml4 ||
type == ObjType_VNode_x86_64_pdpt ||
#include <capabilities.h>
#include <cap_predicates.h>
#include <dispatch.h>
+#include <kcb.h>
#include <paging_kernel_arch.h>
#include <mdb/mdb.h>
#include <mdb/mdb_tree.h>
// If you create more capability types you need to deal with them
// in the table below.
-STATIC_ASSERT(ObjType_Num == 25, "Knowledge of all cap types");
+STATIC_ASSERT(26 == ObjType_Num, "Knowledge of all cap types");
static size_t caps_numobjs(enum objtype type, uint8_t bits, uint8_t objbits)
{
return 1UL << (bits - OBJBITS_DISPATCHER);
}
+ case ObjType_KernelControlBlock:
+ if (bits < OBJBITS_KCB) {
+ return 0;
+ } else {
+ return 1UL << (bits - OBJBITS_KCB);
+ }
+
case ObjType_Kernel:
case ObjType_IRQTable:
case ObjType_IO:
*/
// If you create more capability types you need to deal with them
// in the table below.
-STATIC_ASSERT(ObjType_Num == 25, "Knowledge of all cap types");
+STATIC_ASSERT(26 == ObjType_Num, "Knowledge of all cap types");
static errval_t caps_create(enum objtype type, lpaddr_t lpaddr, uint8_t bits,
uint8_t objbits, size_t numobjs,
// Insert the capability
return set_cap(&dest_caps->cap, &src_cap);
+ case ObjType_KernelControlBlock:
+ assert((1UL << OBJBITS_KCB) >= sizeof(struct dcb));
+ trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_KERNEL_BZERO, 1);
+ memset((void*)lvaddr, 0, 1UL << bits);
+ trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_KERNEL_BZERO, 0);
+
+ for(size_t i = 0; i < numobjs; i++) {
+ // Initialize type specific fields
+ src_cap.u.kernelcontrolblock.kcb = (struct kcb *)
+ (lvaddr + i * (1UL << OBJBITS_DISPATCHER));
+ // Insert the capability
+ err = set_cap(&dest_caps[i].cap, &src_cap);
+ if (err_is_fail(err)) {
+ return err;
+ }
+ }
+ return SYS_ERR_OK;
+
default:
panic("Unhandled capability type or capability of this type cannot"
" be created");
--- /dev/null
+/**
+ * \file
+ * \brief Kernel control block declarations.
+ */
+
+/*
+ * Copyright (c) 2013, ETH Zurich.
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached LICENSE file.
+ * If you do not find this file, copies can be found by writing to:
+ * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
+ */
+
+#ifndef KCB_H
+#define KCB_H
+
+#include <dispatch.h>
+struct dcb;
+
+/**
+ * this is the memory layout of ObjType_KernelControlBlock
+ * this struct should contain all the persistent state that belongs to a
+ * kernel.
+ */
+struct kcb {
+ // mdb root node
+ lvaddr_t mdb_root;
+ // RR scheduler state
+ struct dcb *ring_current;
+ // RBED scheduler state
+ struct dcb *queue_head, *queue_tail;
+ struct dcb *last_disp;
+ // TODO: figure out core-local state that we need to remember
+ // TODO: maybe add a shared part which can replace struct core_data?
+};
+
+#endif