SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /hwcore/exception.c (Article 6) and /hwcore/exception.c (Article 2)


001 /* Copyright (C) 2004  David Decotigny            001 /* Copyright (C) 2004  David Decotigny
002    Copyright (C) 1999  Free Software Foundatio    002    Copyright (C) 1999  Free Software Foundation, Inc.
003                                                   003 
004    This program is free software; you can redi    004    This program is free software; you can redistribute it and/or
005    modify it under the terms of the GNU Genera    005    modify it under the terms of the GNU General Public License
006    as published by the Free Software Foundatio    006    as published by the Free Software Foundation; either version 2
007    of the License, or (at your option) any lat    007    of the License, or (at your option) any later version.
008                                                   008    
009    This program is distributed in the hope tha    009    This program is distributed in the hope that it will be useful,
010    but WITHOUT ANY WARRANTY; without even the     010    but WITHOUT ANY WARRANTY; without even the implied warranty of
011    MERCHANTABILITY or FITNESS FOR A PARTICULAR    011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012    GNU General Public License for more details    012    GNU General Public License for more details.
013                                                   013    
014    You should have received a copy of the GNU     014    You should have received a copy of the GNU General Public License
015    along with this program; if not, write to t    015    along with this program; if not, write to the Free Software
016    Foundation, Inc., 59 Temple Place - Suite 3    016    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
017    USA.                                           017    USA. 
018 */                                                018 */
019 #include "idt.h"                                  019 #include "idt.h"
020 #include "irq.h"                                  020 #include "irq.h"
021                                                   021 
022 #include "exception.h"                            022 #include "exception.h"
023                                                   023 
024 /* array of exception wrappers, defined in exc    024 /* array of exception wrappers, defined in exception_wrappers.S */
025 extern sos_vaddr_t sos_exception_wrapper_array    025 extern sos_vaddr_t sos_exception_wrapper_array[SOS_EXCEPT_NUM];
026                                                   026 
027 /* arrays of exception handlers, shared with e    027 /* arrays of exception handlers, shared with exception_wrappers.S */
028 sos_exception_handler_t sos_exception_handler_    028 sos_exception_handler_t sos_exception_handler_array[SOS_EXCEPT_NUM] =
029   { NULL, };                                      029   { NULL, };
030                                                   030 
031 sos_ret_t sos_exception_subsystem_setup(void)  !! 031 sos_ret_t sos_exceptions_setup(void)
032 {                                                 032 {
033   /* We inidicate that the double fault except !! 033   return SOS_OK;
034      and give its address. this handler is a d << 
035      exception_wrappers.S), and it can NOT be  << 
036      functions below */                        << 
037   return sos_idt_set_handler(SOS_EXCEPT_BASE + << 
038                             (sos_vaddr_t) sos_ << 
039                             0 /* CPL0 routine  << 
040 }                                                 034 }
041                                                   035 
042                                                   036 
043 sos_ret_t sos_exception_set_routine(int except    037 sos_ret_t sos_exception_set_routine(int exception_number,
044                                     sos_except    038                                     sos_exception_handler_t routine)
045 {                                                 039 {
046   sos_ret_t retval;                               040   sos_ret_t retval;
047   sos_ui32_t flags;                               041   sos_ui32_t flags;
048                                                   042   
049   if ((exception_number < 0) || (exception_num    043   if ((exception_number < 0) || (exception_number >= SOS_EXCEPT_NUM))
050     return -SOS_EINVAL;                           044     return -SOS_EINVAL;
051                                                   045 
052   /* Double fault not supported */                046   /* Double fault not supported */
053   if (exception_number == SOS_EXCEPT_DOUBLE_FA    047   if (exception_number == SOS_EXCEPT_DOUBLE_FAULT)
054     return -SOS_ENOSUP;                           048     return -SOS_ENOSUP;
055                                                   049   
056   sos_disable_IRQs(flags);                        050   sos_disable_IRQs(flags);
057                                                   051 
058   retval = SOS_OK;                                052   retval = SOS_OK;
059                                                   053 
060   /* Set the exception routine to be called by    054   /* Set the exception routine to be called by the exception wrapper */
061   sos_exception_handler_array[exception_number    055   sos_exception_handler_array[exception_number] = routine;
062                                                   056 
063   /* If the exception is to be enabled, update    057   /* If the exception is to be enabled, update the IDT with the exception
064      wrapper */                                   058      wrapper */
065   if (routine != NULL)                            059   if (routine != NULL)
066     retval                                        060     retval
067       = sos_idt_set_handler(SOS_EXCEPT_BASE +     061       = sos_idt_set_handler(SOS_EXCEPT_BASE + exception_number,
068                             (sos_vaddr_t) sos_    062                             (sos_vaddr_t) sos_exception_wrapper_array[exception_number],
069                             0 /* CPL0 routine     063                             0 /* CPL0 routine */);
070   else /* Disable the IDT entry */                064   else /* Disable the IDT entry */
071     retval                                        065     retval
072       = sos_idt_set_handler(SOS_EXCEPT_BASE +     066       = sos_idt_set_handler(SOS_EXCEPT_BASE + exception_number,
073                             (sos_vaddr_t)NULL     067                             (sos_vaddr_t)NULL /* No routine => disable IDTE */,
074                             0 /* don't care */    068                             0 /* don't care */);
075                                                   069 
076   sos_restore_IRQs(flags);                        070   sos_restore_IRQs(flags);
077   return retval;                                  071   return retval;
078 }                                                 072 }
079                                                   073 
080                                                   074 
081 sos_exception_handler_t sos_exception_get_rout    075 sos_exception_handler_t sos_exception_get_routine(int exception_number)
082 {                                                 076 {
083   if ((exception_number < 0) || (exception_num    077   if ((exception_number < 0) || (exception_number >= SOS_EXCEPT_NUM))
084     return NULL;                                  078     return NULL;
085                                                   079 
086   /* Double fault not supported */                080   /* Double fault not supported */
087   if (exception_number == SOS_EXCEPT_DOUBLE_FA    081   if (exception_number == SOS_EXCEPT_DOUBLE_FAULT)
088     return NULL;                                  082     return NULL;
089                                                   083   
090   /* Expected to be atomic */                     084   /* Expected to be atomic */
091   return sos_exception_handler_array[exception    085   return sos_exception_handler_array[exception_number];
092 }                                                 086 }
                                                      

source navigation ] diff markup ] identifier search ] general search ]