You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: trap.go
    path of file: ./repos/eggos/kernel
    
    the code of the file until where you have to start completion: package kernel

import (
	"unsafe"

	"github.com/icexin/eggos/drivers/pic"
	"github.com/icexin/eggos/kernel/isyscall"
	"github.com/icexin/eggos/kernel/sys"
	"github.com/icexin/eggos/kernel/trap"
	"github.com/icexin/eggos/log"
)

v
    
func dotrap(tf *trapFrame) {
	if sys.Flags()&_FLAGS_IF != 0 {
		throw("IF should clear")
	}
	my := Mythread()
	// ugly as it is, avoid writeBarrier
	// my.tf = tf
	*(*uintptr)(unsafe.Pointer(&my.tf)) = uintptr(unsafe.Pointer(tf))

	handler := trap.Handler(int(tf.Trapno))
	if handler == nil {
		faultHandler()
		return
	}
	// timer and syscall interrupts are processed synchronously
	if tf.Trapno > 32 && tf.Trapno != 0x80 {
		// pci using level trigger irq, cause dead lock on trap handler
		// FIXME: hard code network irq line
		if tf.Trapno == 43 {
			pic.DisableIRQ(43 - pic.IRQ_BASE)
		}
		wakeIRQ(tf.Trapno)
		return
	}
	handler()
}