Mercurial > ecos
comparison packages/hal/mips/arch/current/src/hal_syscall.c @ 156:b939e9cada46
Merge from eCos master repository on 2001-03-29-21:44:39-BST
| author | jlarmour |
|---|---|
| date | Fri, 06 Apr 2001 17:20:13 +0000 |
| parents | |
| children | e0c0827131d1 |
comparison
equal
deleted
inserted
replaced
| 155:70a4cc6d69d2 | 156:b939e9cada46 |
|---|---|
| 1 //============================================================================= | |
| 2 // | |
| 3 // hal_syscall.c | |
| 4 // | |
| 5 // | |
| 6 // | |
| 7 //============================================================================= | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Red Hat eCos Public License | |
| 12 // Version 1.1 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://www.redhat.com/ | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 22 // released September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Red Hat. | |
| 25 // Portions created by Red Hat are | |
| 26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 27 // All Rights Reserved. | |
| 28 // ------------------------------------------- | |
| 29 // | |
| 30 //####COPYRIGHTEND#### | |
| 31 //============================================================================= | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 34 // Author(s): msalter | |
| 35 // Contributors:msalter | |
| 36 // Date: 2000-11-5 | |
| 37 // Purpose: | |
| 38 // Description: | |
| 39 // | |
| 40 // | |
| 41 // | |
| 42 //####DESCRIPTIONEND#### | |
| 43 // | |
| 44 //============================================================================= | |
| 45 | |
| 46 #include <pkgconf/hal.h> | |
| 47 | |
| 48 #ifdef CYGPKG_REDBOOT | |
| 49 #include <pkgconf/redboot.h> | |
| 50 #endif | |
| 51 | |
| 52 #if defined(CYGSEM_REDBOOT_BSP_SYSCALLS) | |
| 53 | |
| 54 #include <cyg/hal/hal_stub.h> // Our header | |
| 55 #include <cyg/hal/hal_arch.h> // HAL_BREAKINST | |
| 56 #include <cyg/hal/hal_cache.h> // HAL_xCACHE_x | |
| 57 #include <cyg/hal/hal_intr.h> // interrupt disable/restore | |
| 58 | |
| 59 #include <cyg/hal/hal_if.h> // ROM calling interface | |
| 60 #include <cyg/hal/hal_misc.h> // Helper functions | |
| 61 | |
| 62 extern CYG_ADDRWORD __do_syscall(CYG_ADDRWORD func, // syscall function number | |
| 63 CYG_ADDRWORD arg1, CYG_ADDRWORD arg2, // up to four args. | |
| 64 CYG_ADDRWORD arg3, CYG_ADDRWORD arg4, | |
| 65 CYG_ADDRWORD *retval); // syscall return value | |
| 66 | |
| 67 #define SYS_exit 1 | |
| 68 #define SYS_interrupt 1000 | |
| 69 | |
| 70 int | |
| 71 hal_syscall_handler(void) | |
| 72 { | |
| 73 CYG_ADDRWORD func, arg1, arg2, arg3, arg4; | |
| 74 CYG_ADDRWORD err; | |
| 75 | |
| 76 func = get_register(REG_A0); | |
| 77 arg1 = get_register(REG_A1); | |
| 78 arg2 = get_register(REG_A2); | |
| 79 arg3 = get_register(REG_A3); | |
| 80 arg4 = 0; | |
| 81 | |
| 82 put_register(REG_PC, get_register(REG_PC)+4); | |
| 83 | |
| 84 if (func == SYS_exit) { | |
| 85 // We want to stop in exit so that the user may poke around | |
| 86 // to see why his app exited. | |
| 87 return SIGTRAP; | |
| 88 } | |
| 89 | |
| 90 if (func == SYS_interrupt) { | |
| 91 // A console interrupt landed us here. | |
| 92 // Invoke the debug agent so as to cause a SIGINT. | |
| 93 return SIGINT; | |
| 94 } | |
| 95 | |
| 96 if (__do_syscall(func, arg1, arg2, arg3, arg4, &err)) { | |
| 97 put_register(REG_V0, err); | |
| 98 return 0; | |
| 99 } | |
| 100 | |
| 101 return SIGTRAP; | |
| 102 } | |
| 103 | |
| 104 #endif // CYGSEM_REDBOOT_BSP_SYSCALLS |
