Miyoo >> Assembly

INTC


參考資料:
1. pdf
2. lichee
3. mangopi_r
4. allwinner

F1C100S分成FIQ、IRQ兩種中斷,EXT_INT是FIQ中斷,其餘都是IRQ中斷,比較特別的地方是可以透過設定INT_FORCE(INTC_FF_REG),強制觸發IRQ中斷


暫存器


Number代表第幾個bit,如:UART2是3,因此,要Enable UART2中斷的話,則需要設定bit-3(INTC_EN_REG0|= (1 << 3)),Vector代表中斷觸發的來源,也就是儲存在INTC_VECTOR_REG的數值,如:UART2是0x000c,因此,UART2中斷觸發後,INTC_VECTOR_REG內容就是0x000c


main.s

  .global _start
   
  .equiv GPIO_BASE,  0x01c20800 
  .equiv INTC_BASE,  0x01c20400
   
  .equiv PA,         (0x24 * 0)
  .equiv PORT_CFG0,  0x00
  .equiv PORT_DATA,  0x10
   
  .equiv INTC_BASE_ADDR_REG, 0x04
  .equiv INTC_PEND_REG0,     0x10
  .equiv INTC_PEND_REG1,     0x14
  .equiv INTC_EN_REG0,       0x20
  .equiv INTC_EN_REG1,       0x24
  .equiv INTC_MASK_REG0,     0x30
  .equiv INTC_MASK_REG1,     0x34
  .equiv INTC_RESP_REG0,     0x40
  .equiv INTC_RESP_REG1,     0x44
  .equiv INTC_FF_REG0,       0x50
  .equiv INTC_FF_REG1,       0x54
   
  .arm
  .text
_start:
  .long 0xea000016
  .byte 'e', 'G', 'O', 'N', '.', 'B', 'T', '0'
  .long 0, __spl_size
  .byte 'S', 'P', 'L', 2
  .long 0, 0
  .long 0, 0, 0, 0, 0, 0, 0, 0
  .long 0, 0, 0, 0, 0, 0, 0, 0
      
_vector:
  b reset
  b .
  b .
  b .
  b .
  b .
  ldr pc, _irq
  b .
   
_irq: .word irq_handler
   
irq_handler:
  ldr r0, =GPIO_BASE
  ldr r1, =0x00
  str r1, [r0, #(PA + PORT_DATA)]
  
  ldr r0, =INTC_BASE
  ldr r1, =0x00000000
  str r1, [r0, #INTC_FF_REG0]
  ldr r1, =0xffffffff
  str r1, [r0, #INTC_PEND_REG0]
  subs pc, lr, #4
   
reset:
  mrc p15, 0, r0, c1, c0, 0
  bic r0, #(1 << 13)
  mcr p15, 0, r0, c1, c0, 0
   
  adr r0, _vector
  mrc p15, 0, r2, c1, c0, 0
  ands r2, r2, #(1 << 13)
  ldreq r1, =0x00000000
  ldrne r1, =0xffff0000
  ldmia r0!, {r2-r8, r10}
  stmia r1!, {r2-r8, r10}
  ldmia r0!, {r2-r8, r10}
  stmia r1!, {r2-r8, r10}
   
  mrs r0, cpsr
  bic r0, #0x80
  msr cpsr_c, r0
   
  ldr r0, =INTC_BASE
  ldr r1, =(1 << 3)
  str r1, [r0, #INTC_EN_REG0]
  ldr r1, =0x00000000
  str r1, [r0, #INTC_MASK_REG0]
   
  ldr r0, =GPIO_BASE
  ldr r1, =0x10
  str r1, [r0, #(PA + PORT_CFG0)]
  ldr r1, =0x02
  str r1, [r0, #(PA + PORT_DATA)]
  
0:
  ldr r0, =GPIO_BASE
  ldr r1, =0x02
  str r1, [r0, #(PA + PORT_DATA)] 
  ldr r0, =50000
1:
  subs r0, #1
  bne 1b
    
  ldr r0, =INTC_BASE
  ldr r1, =(1 << 3)
  str r1, [r0, #INTC_FF_REG0]
  ldr r0, =50000
1:
  subs r0, #1
  bne 1b
  
  b 0b
  .end

完成


返回上一頁