XINU
Functions | Variables
evec.c File Reference
#include <xinu.h>
#include <stdio.h>
Include dependency graph for evec.c:

Go to the source code of this file.

Functions

int32 initintc ()
 
void irq_dispatch ()
 
int32 set_evec (uint32 xnum, uint32 handler)
 
void userret (void)
 プロセスが最上位の関数に戻る時に呼ばれる。現在のプロセスを終了させる。 More...
 

Variables

char expmsg1 [] = "Unhandled exception. Link Register: 0x%x"
 
char expmsg2 [] = "**** EXCEPTION ****"
 
uint32 intc_vector [128]
 

Function Documentation

◆ initintc()

int32 initintc ( void  )

Definition at line 18 of file evec.c.

References INTC_SYSCONFIG_SOFTRESET, INTC_SYSSTATUS_RESETDONE, OK, intc_csreg::sysconfig, and intc_csreg::sysstatus.

Referenced by platinit().

19 {
20  struct intc_csreg *csrptr = (struct intc_csreg *)0x48200000;
21 
22  /* Reset the interrupt controller */
23 
25 
26  /* Wait until reset is complete */
27 
28  while((csrptr->sysstatus & INTC_SYSSTATUS_RESETDONE) == 0);
29 
30  return OK;
31 }
#define INTC_SYSCONFIG_SOFTRESET
Definition: interrupt.h:38
uint32 sysstatus
Definition: interrupt.h:22
#define OK
処理が成功した場合
Definition: kernel.h:77
#define INTC_SYSSTATUS_RESETDONE
Definition: interrupt.h:39
uint32 sysconfig
Definition: interrupt.h:21
Here is the caller graph for this function:

◆ irq_dispatch()

void irq_dispatch ( )

Definition at line 72 of file evec.c.

References intc_csreg::control, currpid, DEFER_START, DEFER_STOP, disable(), INTC_CONTROL_NEWIRQAGR, intc_vector, kprintf(), panic(), proctab, resched_cntl(), intc_csreg::sir_irq, and trap().

73 {
74  struct intc_csreg *csrptr = (struct intc_csreg *)0x48200000;
75  uint32 xnum; /* Interrupt number of device */
76  interrupt (*handler)(); /* Pointer to handler function */
77 
78  /* Get the interrupt number from the Interrupt controller */
79 
80  xnum = csrptr->sir_irq & 0x7F;
81 
82  /* Defer scheduling until interrupt is acknowledged */
83 
85 
86  /* If a handler is set for the interrupt, call it */
87 
88  if(intc_vector[xnum]) {
89  handler = ( interrupt(*)() )intc_vector[xnum];
90  handler(xnum);
91  }
92 
93  /* Acknowledge the interrupt */
94 
95  csrptr->control |= (INTC_CONTROL_NEWIRQAGR);
96 
97  /* Resume scheduling */
98 
100 }
#define INTC_CONTROL_NEWIRQAGR
Definition: interrupt.h:43
uint32 intc_vector[128]
Definition: evec.c:11
status resched_cntl(int32)
再スケジューリングを延期させるか、もしくは許可させるかを制御する。
Definition: resched.c:81
#define DEFER_STOP
遅延リスケジューリングの停止
Definition: resched.h:10
#define DEFER_START
遅延リスケジューリングの開始
Definition: resched.h:8
void interrupt
割り込みハンドラ 返り値の型
Definition: kernel.h:55
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
uint32 control
Definition: interrupt.h:26
uint32 sir_irq
Definition: interrupt.h:24
Here is the call graph for this function:

◆ set_evec()

int32 set_evec ( uint32  xnum,
uint32  handler 
)

Definition at line 37 of file evec.c.

References intc_csreg::banks, intc_vector, intc_bank::mir, OK, and SYSERR.

Referenced by clkinit(), ethinit(), gpioinit(), and ttyinit().

38 {
39  struct intc_csreg *csrptr = (struct intc_csreg *)0x48200000;
40  uint32 bank; /* bank number in int controller */
41  uint32 mask; /* used to set bits in bank */
42 
43  /* There are only 127 interrupts allowed 0-126 */
44 
45  if(xnum > 127) {
46  return SYSERR;
47  }
48 
49  /* Install the handler */
50 
51  intc_vector[xnum] = handler;
52 
53  /* Get the bank number based on interrupt number */
54 
55  bank = (xnum/32);
56 
57  /* Get the bit inside the bank */
58 
59  mask = (0x00000001 << (xnum%32));
60 
61  /* Reset the bit to enable that interrupt number */
62 
63  csrptr->banks[bank].mir &= (~mask);
64 
65  return OK;
66 }
#define SYSERR
処理が失敗した場合
Definition: kernel.h:79
uint32 mir
Definition: interrupt.h:9
struct intc_bank banks[4]
Definition: interrupt.h:34
#define OK
処理が成功した場合
Definition: kernel.h:77
uint32 intc_vector[128]
Definition: evec.c:11
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
Here is the caller graph for this function:

◆ userret()

void userret ( void  )

プロセスが最上位の関数に戻る時に呼ばれる。現在のプロセスを終了させる。

Note
プロセス作成時に、戻りアドレスとしてuserret()がスタックに積まれる。

Definition at line 11 of file userret.c.

References getpid(), and kill().

12 {
13  kill(getpid()); /* Force process to exit */
14 }
syscall kill(pid32)
指定のプロセスを終了させ、システムから終了させたプロセス情報を取り除く。
Definition: kill.c:31
pid32 getpid(void)
現在実行中のプロセスIDを返す。
Definition: getpid.c:11
Here is the call graph for this function:

Variable Documentation

◆ expmsg1

char expmsg1[] = "Unhandled exception. Link Register: 0x%x"

Definition at line 12 of file evec.c.

◆ expmsg2

char expmsg2[] = "**** EXCEPTION ****"

Definition at line 13 of file evec.c.

◆ intc_vector

uint32 intc_vector[128]

Definition at line 11 of file evec.c.

Referenced by irq_dispatch(), and set_evec().