[arch][m68k] add exception and irq processing
-Add interrupt controller and timer support for qemu virt machine -Switch tty read to irq driven as well
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
|
||||
void arch_early_init(void) {
|
||||
LTRACE;
|
||||
|
||||
// set the exception vector base
|
||||
extern uint32_t exc_vectors[256];
|
||||
asm("movec %0, %%vbr" :: "r"(exc_vectors));
|
||||
}
|
||||
|
||||
void arch_init(void) {
|
||||
|
||||
@@ -26,3 +26,4 @@ FUNCTION(m68k_context_switch)
|
||||
// return to new PC
|
||||
rts
|
||||
END_FUNCTION(m68k_context_switch)
|
||||
|
||||
|
||||
37
arch/m68k/exceptions.c
Normal file
37
arch/m68k/exceptions.c
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Travis Geiselbrecht
|
||||
*
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#include <arch/m68k.h>
|
||||
#include <inttypes.h>
|
||||
#include <lk/debug.h>
|
||||
#include <lk/trace.h>
|
||||
#include <kernel/thread.h>
|
||||
|
||||
#define LOCAL_TRACE 0
|
||||
|
||||
// defined in platform interrupt controller
|
||||
extern enum handler_return m68k_platform_irq(uint8_t irq);
|
||||
|
||||
void m68k_exception(void *frame, uint8_t code) {
|
||||
LTRACEF("frame %p, code %hhu\n", frame, code);
|
||||
|
||||
panic("unimplemented exception %hhu\n", code);
|
||||
}
|
||||
|
||||
void m68k_irq(void *frame, uint8_t code) {
|
||||
LTRACEF("frame %p, code %hhu\n", frame, code);
|
||||
|
||||
if (unlikely(code == 0)) {
|
||||
// spurious interrupt
|
||||
return;
|
||||
}
|
||||
|
||||
enum handler_return ret = m68k_platform_irq(code);
|
||||
if (ret == INT_RESCHEDULE) {
|
||||
thread_preempt();
|
||||
}
|
||||
}
|
||||
83
arch/m68k/exceptions_asm.S
Normal file
83
arch/m68k/exceptions_asm.S
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Travis Geiselbrecht
|
||||
*
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#include <lk/asm.h>
|
||||
|
||||
.text
|
||||
|
||||
.macro irq_vector n
|
||||
m68k_irq_vector_\n:
|
||||
moveml %d0-%d7/%a0-%a6, %sp@-
|
||||
|
||||
pea \n
|
||||
movel %sp,%sp@-
|
||||
jsr m68k_irq
|
||||
addaw #8, %sp
|
||||
|
||||
moveml %sp@+, %d0-%d7/%a0-%a6
|
||||
rte
|
||||
.endm
|
||||
|
||||
irq_vector 0
|
||||
irq_vector 1
|
||||
irq_vector 2
|
||||
irq_vector 3
|
||||
irq_vector 4
|
||||
irq_vector 5
|
||||
irq_vector 6
|
||||
irq_vector 7
|
||||
|
||||
.macro exception_vector name n
|
||||
\name:
|
||||
moveml %d0-%d7/%a0-%a6, %sp@-
|
||||
|
||||
pea \n
|
||||
movel %sp,%sp@-
|
||||
jsr m68k_exception
|
||||
addaw #8, %sp
|
||||
|
||||
moveml %sp@+, %d0-%d7/%a0-%a6
|
||||
rte
|
||||
.endm
|
||||
|
||||
exception_vector m68k_access_fault 2
|
||||
exception_vector m68k_address_error 3
|
||||
exception_vector m68k_illegal_vector 4
|
||||
exception_vector m68k_div_by_zero 5
|
||||
exception_vector m68k_chk 6
|
||||
exception_vector m68k_trap 7
|
||||
exception_vector m68k_priv_violation 8
|
||||
exception_vector m68k_trace 9
|
||||
exception_vector m68k_unimp_aline 10
|
||||
exception_vector m68k_unimp_fline 11
|
||||
|
||||
.section .text.vectab
|
||||
.align 4
|
||||
DATA(exc_vectors)
|
||||
.org 0x8
|
||||
.long m68k_access_fault
|
||||
.long m68k_address_error
|
||||
.long m68k_illegal_vector
|
||||
.long m68k_div_by_zero
|
||||
.long m68k_chk
|
||||
.long m68k_trap
|
||||
.long m68k_priv_violation
|
||||
.long m68k_trace
|
||||
.long m68k_unimp_aline
|
||||
.long m68k_unimp_fline
|
||||
.org 0x60
|
||||
.long m68k_irq_vector_0
|
||||
.long m68k_irq_vector_1
|
||||
.long m68k_irq_vector_2
|
||||
.long m68k_irq_vector_3
|
||||
.long m68k_irq_vector_4
|
||||
.long m68k_irq_vector_5
|
||||
.long m68k_irq_vector_6
|
||||
.long m68k_irq_vector_7
|
||||
.org 4*256
|
||||
END_DATA(exc_vectors)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Travis Geiselbrecht
|
||||
* Copyright (c) 2021 Travis Geiselbrecht
|
||||
*
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Travis Geiselbrecht
|
||||
*
|
||||
* Use of this source code is governed by a MIT-style
|
||||
* license that can be found in the LICENSE file or at
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if 0
|
||||
static inline uint32_t mb_read_msr(void) {
|
||||
uint32_t temp;
|
||||
__asm__ volatile(
|
||||
"mfs %0, rmsr;" : "=r" (temp));
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
static inline void mb_write_msr(uint32_t val) {
|
||||
__asm__ volatile(
|
||||
"mts rmsr, %0" :: "r" (val));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,11 +5,12 @@ MODULE := $(LOCAL_DIR)
|
||||
MODULE_SRCS += \
|
||||
$(LOCAL_DIR)/arch.c \
|
||||
$(LOCAL_DIR)/asm.S \
|
||||
$(LOCAL_DIR)/exceptions.c \
|
||||
$(LOCAL_DIR)/exceptions_asm.S \
|
||||
$(LOCAL_DIR)/start.S \
|
||||
$(LOCAL_DIR)/thread.c \
|
||||
|
||||
# $(LOCAL_DIR)/asm.S \
|
||||
$(LOCAL_DIR)/exceptions.c \
|
||||
$(LOCAL_DIR)/cache.c \
|
||||
$(LOCAL_DIR)/cache-ops.S \
|
||||
$(LOCAL_DIR)/ops.S \
|
||||
|
||||
Reference in New Issue
Block a user