Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Mar 2015 05:53:08 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279623 - head/sys/powerpc/booke
Message-ID:  <201503050553.t255r8RV037291@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Thu Mar  5 05:53:08 2015
New Revision: 279623
URL: https://svnweb.freebsd.org/changeset/base/279623

Log:
  Move IVOR setup from assembler to C, decreasing required assumptions about
  address formats for trap handlers.

Modified:
  head/sys/powerpc/booke/locore.S
  head/sys/powerpc/booke/machdep.c

Modified: head/sys/powerpc/booke/locore.S
==============================================================================
--- head/sys/powerpc/booke/locore.S	Thu Mar  5 03:11:47 2015	(r279622)
+++ head/sys/powerpc/booke/locore.S	Thu Mar  5 05:53:08 2015	(r279623)
@@ -536,42 +536,6 @@ __boot_page_padding:
 /* locore subroutines */
 /************************************************************************/
 
-ivor_setup:
-	/* Set base address of interrupt handler routines */
-	lis	%r3, interrupt_vector_base@h
-	mtspr	SPR_IVPR, %r3
-
-	/* Assign interrupt handler routines offsets */
-	li	%r3, int_critical_input@l
-	mtspr	SPR_IVOR0, %r3
-	li	%r3, int_machine_check@l
-	mtspr	SPR_IVOR1, %r3
-	li	%r3, int_data_storage@l
-	mtspr	SPR_IVOR2, %r3
-	li	%r3, int_instr_storage@l
-	mtspr	SPR_IVOR3, %r3
-	li	%r3, int_external_input@l
-	mtspr	SPR_IVOR4, %r3
-	li	%r3, int_alignment@l
-	mtspr	SPR_IVOR5, %r3
-	li	%r3, int_program@l
-	mtspr	SPR_IVOR6, %r3
-	li	%r3, int_syscall@l
-	mtspr	SPR_IVOR8, %r3
-	li	%r3, int_decrementer@l
-	mtspr	SPR_IVOR10, %r3
-	li	%r3, int_fixed_interval_timer@l
-	mtspr	SPR_IVOR11, %r3
-	li	%r3, int_watchdog@l
-	mtspr	SPR_IVOR12, %r3
-	li	%r3, int_data_tlb_error@l
-	mtspr	SPR_IVOR13, %r3
-	li	%r3, int_inst_tlb_error@l
-	mtspr	SPR_IVOR14, %r3
-	li	%r3, int_debug@l
-	mtspr	SPR_IVOR15, %r3
-	blr
-
 /*
  * void tid_flush(tlbtid_t tid);
  *

Modified: head/sys/powerpc/booke/machdep.c
==============================================================================
--- head/sys/powerpc/booke/machdep.c	Thu Mar  5 03:11:47 2015	(r279622)
+++ head/sys/powerpc/booke/machdep.c	Thu Mar  5 05:53:08 2015	(r279623)
@@ -187,6 +187,51 @@ SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST,
 void print_kernel_section_addr(void);
 void print_kenv(void);
 u_int booke_init(uint32_t, uint32_t);
+void ivor_setup(void);
+
+extern void *interrupt_vector_base;
+extern void *int_critical_input;
+extern void *int_machine_check;
+extern void *int_data_storage;
+extern void *int_instr_storage;
+extern void *int_external_input;
+extern void *int_alignment;
+extern void *int_program;
+extern void *int_syscall;
+extern void *int_decrementer;
+extern void *int_fixed_interval_timer;
+extern void *int_watchdog;
+extern void *int_data_tlb_error;
+extern void *int_inst_tlb_error;
+extern void *int_debug;
+
+#define SET_TRAP(ivor, handler) \
+	KASSERT(((uintptr_t)(&handler) & ~0xffffUL) == \
+	    ((uintptr_t)(&interrupt_vector_base) & ~0xffffUL), \
+	    ("Handler " #handler " too far from interrupt vector base")); \
+	mtspr(ivor, (uintptr_t)(&handler) & 0xffffUL);
+
+void
+ivor_setup(void)
+{
+
+	mtspr(SPR_IVPR, ((uintptr_t)&interrupt_vector_base) & 0xffff0000);
+
+	SET_TRAP(SPR_IVOR0, int_critical_input);
+	SET_TRAP(SPR_IVOR1, int_machine_check);
+	SET_TRAP(SPR_IVOR2, int_data_storage);
+	SET_TRAP(SPR_IVOR3, int_instr_storage);
+	SET_TRAP(SPR_IVOR4, int_external_input);
+	SET_TRAP(SPR_IVOR5, int_alignment);
+	SET_TRAP(SPR_IVOR6, int_program);
+	SET_TRAP(SPR_IVOR8, int_syscall);
+	SET_TRAP(SPR_IVOR10, int_decrementer);
+	SET_TRAP(SPR_IVOR11, int_fixed_interval_timer);
+	SET_TRAP(SPR_IVOR12, int_watchdog);
+	SET_TRAP(SPR_IVOR13, int_data_tlb_error);
+	SET_TRAP(SPR_IVOR14, int_inst_tlb_error);
+	SET_TRAP(SPR_IVOR15, int_debug);
+}
 
 static void
 cpu_booke_startup(void *dummy)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503050553.t255r8RV037291>