#define PrintDebug(fmt, args...)
#endif
+#ifdef CONFIG_DEBUG_APIC
+static char *shorthand_str[] = {
+ "(no shorthand)",
+ "(self)",
+ "(all)",
+ "(all-but-me)",
+};
+
+static char *deliverymode_str[] = {
+ "(fixed)",
+ "(lowest priority)",
+ "(SMI)",
+ "(reserved)",
+ "(NMI)",
+ "(INIT)",
+ "(Start Up)",
+ "(ExtInt)",
+};
+#endif
typedef enum { APIC_TMR_INT, APIC_THERM_INT, APIC_PERF_INT,
APIC_LINT0_INT, APIC_LINT1_INT, APIC_ERR_INT } apic_irq_type_t;
if (irq_num <= 15) {
-// PrintError("apic %u: core ?: Attempting to raise an invalid interrupt: %d\n", apic->lapic_id.val,irq_num);
+ PrintError("apic %u: core ?: Attempting to raise an invalid interrupt: %d\n", apic->lapic_id.val,irq_num);
return -1;
}
return 1;
} else {
PrintDebug("apic %u core %u: rejecting clustered IRQ (mda 0x%x != log_dst 0x%x)\n",
- dst_apic->lapic_id.val, dst_core->cpu_id, mda, dst_
+ dst_apic->lapic_id.val, dst_core->cpu_id, mda,
dst_apic->log_dst.dst_log_id);
return 0;
}
dst_core->segments.cs.base = vector << 12;
PrintDebug(" SIPI delivery (0x%x -> 0x%x:0x0) to core %u\n",
- vec, dst_core->segments.cs.selector, dst_core->cpu_id);
+ vector, dst_core->segments.cs.selector, dst_core->cpu_id);
// Maybe need to adjust the APIC?
// We transition the target core to SIPI state
struct int_cmd_reg * icr) {
struct apic_state * dest_apic = NULL;
- PrintDebug("icc_bus: icc_bus=%p, src_apic=%u, icr_data=%llx, extirq=%u\n",
- icc_bus, src_apic, icr_data, extirq);
+ PrintDebug("route_ipi: src_apic=%p, icr_data=%x",
+ src_apic, icr_val);
if ((icr->dst_mode == 0) && (icr->dst >= apic_dev->num_apics)) {
- PrintError("icc_bus: Attempted send to unregistered apic id=%u\n",
+ PrintError("route_ipi: Attempted send to unregistered apic id=%u\n",
icr->dst);
return -1;
}
dest_apic = &(apic_dev->apics[icr->dst]);
- PrintDebug("icc_bus: IPI %s %u from %s %u to %s %s %u (icr=0x%llx, extirq=%u)\n",
+ PrintDebug("route_ipi: IPI %s %u from apic %p to %s %s %u (icr=0x%llx)\n",
deliverymode_str[icr->del_mode],
icr->vec,
src_apic,
(icr->dst_mode == 0) ? "(physical)" : "(logical)",
shorthand_str[icr->dst_shorthand],
icr->dst,
- icr->val,
- extirq);
+ icr->val);
switch (icr->dst_shorthand) {
struct apic_dev_state * apic_dev = (struct apic_dev_state *)(dev->private_data);
struct apic_state * apic = &(apic_dev->apics[dst]);
+ PrintDebug("apic %u core ?: raising interrupt IRQ %u (dst = %u).\n", apic->lapic_id.val, irq, dst);
+
activate_apic_irq(apic, irq);
if (V3_Get_CPU() != dst) {
*req_location &= ~flag;
} else {
// do nothing...
- PrintDebug("apic %u: core %u: begin irq for %d ignored since I don't own it\n",
- apic->lapic_id.val, info->cpu_id, irq);
+ //PrintDebug("apic %u: core %u: begin irq for %d ignored since I don't own it\n",
+ // apic->lapic_id.val, core->cpu_id, irq);
}
return 0;
// raise irq
PrintDebug("apic %u: core %u: Raising APIC Timer interrupt (periodic=%d) (icnt=%d) (div=%d)\n",
- apic->lapic_id.val, info->cpu_id,
+ apic->lapic_id.val, core->cpu_id,
apic->tmr_vec_tbl.tmr_mode, apic->tmr_init_cnt, shift_num);
if (apic_intr_pending(core, priv_data)) {
PrintDebug("apic %u: core %u: Overriding pending IRQ %d\n",
- apic->lapic_id.val, info->cpu_id,
- apic_get_intr_number(info, priv_data));
+ apic->lapic_id.val, core->cpu_id,
+ apic_get_intr_number(core, priv_data));
}
if (activate_internal_irq(apic, APIC_TMR_INT) == -1) {
ulong_t pageListAddr;
ulong_t kernEnd;
+
+ memset(&s_freeList, 0, sizeof(struct Page_List));
+
KASSERT(bootInfo->memSizeKB > 0);
+ Print("Booting with %d KB memory\n", bootInfo->memSizeKB);
/*
* Before we do anything, switch from setup.asm's temporary GDT
/* Initialize the kernel heap */
// Init_Heap(HIGHMEM_START, KERNEL_HEAP_SIZE);
+
+ Print("Initing heap\n");
Init_Heap(kernEnd, KERNEL_HEAP_SIZE);
Print("%uKB memory detected, %u pages in freelist, %d bytes in kernel heap\n",
- bootInfo->memSizeKB, g_freePageCount, KERNEL_HEAP_SIZE);
+ bootInfo->memSizeKB, g_freePageCount, KERNEL_HEAP_SIZE);
}
/*
#include <geekos/int.h>
#include <geekos/fmtout.h>
#include <geekos/screen.h>
+#include <geekos/vm_cons.h>
/*
* Information sources for VT100 and ANSI escape sequences:
* Public functions
* ---------------------------------------------------------------------- */
-/*
- * Initialize the screen module.
- */
-void Init_Screen(void)
-{
- bool iflag = Begin_Int_Atomic();
-
- s_cons.row = s_cons.col = 0;
- s_cons.currentAttr = DEFAULT_ATTRIBUTE;
- Clear_Screen();
-
- End_Int_Atomic(iflag);
- Print("Screen Inited\n");
-}
/*
* Clear the screen using the current attribute.
/* Support for Print(). */
static void Print_Emit(struct Output_Sink *o, int ch) { Put_Char_Imp(ch); }
static void Print_Finish(struct Output_Sink *o) { Update_Cursor(); }
-static struct Output_Sink s_outputSink = { &Print_Emit, &Print_Finish };
+static struct Output_Sink s_outputSink;
/*
* Print to console using printf()-style formatting.
PrintInternal(fmt, ap);
End_Int_Atomic(iflag);
}
+
+
+/*
+ * Initialize the screen module.
+ */
+void Init_Screen(void)
+{
+ bool iflag = Begin_Int_Atomic();
+
+ s_outputSink.Emit = &Print_Emit;
+ s_outputSink.Finish = &Print_Finish;
+
+ s_cons.row = s_cons.col = 0;
+ s_cons.currentAttr = DEFAULT_ATTRIBUTE;
+ Clear_Screen();
+
+ End_Int_Atomic(iflag);
+ Print("Screen Inited\n");
+}