OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-intsyscall.S] - Diff between revs 506 and 530

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 506 Rev 530
Line 6... Line 6...
        User IRQ and system call simultaneous interrupt test
        User IRQ and system call simultaneous interrupt test
 
 
        Within the test we'll use following global variables:
        Within the test we'll use following global variables:
 
 
        r15 syscall interrupt counter
        r15 syscall interrupt counter
        r16 syscall function counter
        r6 syscall function counter
        r17 irq interrupt counter
        r10 irq interrupt counter
        r18 intgen's base address
        r12 intgen's base address
 
 
 
 
        The test does the following:
        The test does the following:
        Uses the intgen module to schedule interrupts to see if they clash
        Uses the intgen module to schedule interrupts to see if they clash
        with system calls.
        with system calls.
Line 75... Line 75...
 
 
/* =================================================== [ User interrupt ] === */
/* =================================================== [ User interrupt ] === */
        .org 0x800
        .org 0x800
        .global _user_irq_handler
        .global _user_irq_handler
_user_irq_handler:
_user_irq_handler:
        l.addi r17, r17, 1
        l.addi r10, r10, 1
        /* Report values , 0x00000800 == user interrupt report*/
        /* Report values , 0x00000800 == user interrupt report*/
        l.ori r3, r0, 0x0800
        l.ori r3, r0, 0x0800
        l.nop 2
        l.nop 2
        l.or r3, r0, r17
        l.or r3, r0, r10
        l.nop 2
        l.nop 2
        /* TODO - propably confirm it was intgen's IRQ that caused this */
        /* TODO - propably confirm it was intgen's IRQ that caused this */
        /* Clear interrupt source */
        /* Clear interrupt source */
        l.ori   r7, r18, 0x1    /* intgen IRQ clear address */
        l.ori   r7, r12, 0x1    /* intgen IRQ clear address */
        l.sb    0(r7), r0       /* Any write clears the bit */
        l.sb    0(r7), r0       /* Any write clears the bit */
        /* Clear OR1200 PICSR */
        /* Clear OR1200 PICSR */
        l.mfspr r7, r0, SPR_PICSR
        l.mfspr r7, r0, SPR_PICSR
        l.mtspr r0, r7, SPR_PICSR
        l.mtspr r0, r7, SPR_PICSR
 
 
Line 105... Line 105...
        l.ori r4, r0, SPR_SR_IEE|SPR_SR_TEE
        l.ori r4, r0, SPR_SR_IEE|SPR_SR_TEE
        l.ori r5, r0, 0xffff
        l.ori r5, r0, 0xffff
        l.xor r5, r5, r4
        l.xor r5, r5, r4
        l.and r5, r7, r5 /* New SR without interrupt bits set */
        l.and r5, r7, r5 /* New SR without interrupt bits set */
        l.mtspr r0, r5, SPR_ESR_BASE /* SR after l.rfe */
        l.mtspr r0, r5, SPR_ESR_BASE /* SR after l.rfe */
        /* Report values , 0x00000c00 == tick timer report*/
        /* Report values , 0x00000c00 == system call report*/
        l.ori r3, r0, 0x0c00
        l.ori r3, r0, 0x0c00
        l.nop 2
        l.nop 2
        /* Get syscall number */
        /* Get syscall number */
        l.lwz r3, -4(r8) /* r8 = load(EPCR-4)= PC of l.sys that caused this */
        l.lwz r3, -4(r8) /* r8 = load(EPCR-4)= PC of l.sys that caused this */
        l.andi r3, r3, 0xffff /* get 16-bit immediate syscall number */
        l.andi r3, r3, 0xffff /* get 16-bit immediate syscall number */
Line 133... Line 133...
        l.nop
        l.nop
 
 
/* =================================================== [ main ] === */
/* =================================================== [ main ] === */
.global _main
.global _main
_main:
_main:
        l.movhi r15, 0
 
        l.movhi r16, 0
 
        l.movhi r17, 0
 
 
 
        #
        #
        # unmask (enable) all ints
        # unmask (enable) all ints
        #
        #
        l.movhi r5,0xffff
        l.movhi r5,0xffff
Line 149... Line 146...
        /* Enable Interrupts */
        /* Enable Interrupts */
        l.mfspr r6,r0,SPR_SR
        l.mfspr r6,r0,SPR_SR
        l.ori   r6,r6,SPR_SR_IEE
        l.ori   r6,r6,SPR_SR_IEE
        l.mtspr r0,r6,SPR_SR
        l.mtspr r0,r6,SPR_SR
 
 
 
        l.movhi r15, 0
 
        l.movhi r6, 0
 
        l.movhi r10, 0
 
 
 
 
 
 
        // Assumes r18 is intgen's base address
        // Assumes r12 is intgen's base address
        l.movhi r18,hi(INTGEN_BASE)
        l.movhi r12,hi(INTGEN_BASE)
 
 
#define INTGEN_LOAD(x)  \
#define INTGEN_LOAD(x)  \
        l.ori   r5,r0,lo(x)     ;\
        l.ori   r5,r0,lo(x)     ;\
        l.sb    0(r18),r5
        l.sb    0(r12),r5
 
 
 
 
        /* Test begin */
        /* Test begin */
 
 
        l.nop
        l.nop
Line 177... Line 179...
        l.nop
        l.nop
        l.sys 0x4
        l.sys 0x4
        l.nop
        l.nop
        l.ori   r5,r0,1
        l.ori   r5,r0,1
        l.sys 0x5
        l.sys 0x5
        l.sb    0(r18),r5
        l.sb    0(r12),r5
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.nop
        l.sfnei r16, 0xf /* Should equal 15, 0xf */
        l.sfnei r6, 0xf /* Should equal 15, 0xf */
        l.bf _fail
        l.bf _fail
        l.nop
        l.nop
 
 
        l.movhi r3, hi(0x8000000d)
        l.movhi r3, hi(0x8000000d)
        l.ori r3, r3, lo(0x8000000d)
        l.ori r3, r3, lo(0x8000000d)
Line 202... Line 204...
_syscall_function:
_syscall_function:
        /* r7 and r8 hold actual real ESR and EPCR, respectively */
        /* r7 and r8 hold actual real ESR and EPCR, respectively */
        /* We'll restore them now */
        /* We'll restore them now */
        l.mtspr r0, r7, SPR_ESR_BASE /* SR before syscall */
        l.mtspr r0, r7, SPR_ESR_BASE /* SR before syscall */
        l.mtspr r0, r8, SPR_EPCR_BASE
        l.mtspr r0, r8, SPR_EPCR_BASE
        l.add r16, r16, r3 /* Add syscall number to our counter */
        l.add r6, r6, r3 /* Add syscall number to our counter */
        l.movhi r4, hi(0x00400000) /* 4MB mark of memory */
        l.movhi r4, hi(0x00400000) /* 4MB mark of memory */
        /* Ensure memory access OK */
        /* Ensure memory access OK */
        l.slli r3, r3, 2 /* Turn syscall number into a word address (<< 2) */
        l.slli r3, r3, 2 /* Turn syscall number into a word address (<< 2) */
        l.add r4, r4, r3 /* Access this offset from 4MB mark */
        l.add r4, r4, r3 /* Access this offset from 4MB mark */
        l.sw 0(r4), r16 /* Do a write to memory */
        l.sw 0(r4), r6 /* Do a write to memory */
        l.lwz r16, 0(r4) /* Do a read from memory */
        l.lwz r6, 0(r4) /* Do a read from memory */
        /* Report running value of syscall counter */
        /* Report running value of syscall counter */
        l.or r3, r0, r16
        l.or r3, r0, r6
        l.nop 2
        l.nop 2
        l.rfe /* Now continue from where we had the l.sys */
        l.rfe /* Now continue from where we had the l.sys */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.