PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/freedos/source/kernel/kernel/error.c

https://github.com/vvnikitin/sdcboot
C | 95 lines | 53 code | 9 blank | 33 comment | 2 complexity | 976cf68643973da1576ebe38b10564f5 MD5 | raw file
Possible License(s): GPL-2.0, 0BSD, LGPL-2.0
  1. /****************************************************************/
  2. /* */
  3. /* error.c */
  4. /* */
  5. /* Main Kernel Error Handler Functions */
  6. /* */
  7. /* Copyright (c) 1995 */
  8. /* Pasquale J. Villani */
  9. /* All Rights Reserved */
  10. /* */
  11. /* This file is part of DOS-C. */
  12. /* */
  13. /* DOS-C is free software; you can redistribute it and/or */
  14. /* modify it under the terms of the GNU General Public License */
  15. /* as published by the Free Software Foundation; either version */
  16. /* 2, or (at your option) any later version. */
  17. /* */
  18. /* DOS-C is distributed in the hope that it will be useful, but */
  19. /* WITHOUT ANY WARRANTY; without even the implied warranty of */
  20. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
  21. /* the GNU General Public License for more details. */
  22. /* */
  23. /* You should have received a copy of the GNU General Public */
  24. /* License along with DOS-C; see the file COPYING. If not, */
  25. /* write to the Free Software Foundation, 675 Mass Ave, */
  26. /* Cambridge, MA 02139, USA. */
  27. /****************************************************************/
  28. #include "portab.h"
  29. #ifdef VERSION_STRINGS
  30. static BYTE *errorRcsId =
  31. "$Id: error.c 709 2003-09-24 19:34:11Z bartoldeman $";
  32. #endif
  33. #include "globals.h"
  34. #ifdef DEBUG
  35. /* error registers */
  36. VOID dump(void)
  37. {
  38. printf("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n",
  39. error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS);
  40. printf("AX:%04x BX:%04x CX:%04x DX:%04x\n",
  41. error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX);
  42. printf("SI:%04x DI:%04x DS:%04x ES:%04x\n",
  43. error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES);
  44. }
  45. #endif
  46. /* issue a panic message for corrupted data structures */
  47. VOID panic(BYTE * s)
  48. {
  49. put_string("\nPANIC: ");
  50. put_string(s);
  51. put_string("\nSystem halted");
  52. for (;;) ;
  53. }
  54. #ifdef IPL
  55. /* issue an internal error message */
  56. VOID fatal(BYTE * err_msg)
  57. {
  58. printf("\nInternal IPL error - %s\nSystem halted\n", err_msg);
  59. exit(-1);
  60. }
  61. #else
  62. /* issue an internal error message */
  63. #if 0
  64. VOID fatal(BYTE * err_msg)
  65. {
  66. printf("\nInternal kernel error - \n");
  67. panic(err_msg);
  68. }
  69. #endif
  70. #endif
  71. /* Abort, retry or fail for character devices */
  72. COUNT char_error(request * rq, struct dhdr FAR * lpDevice)
  73. {
  74. CritErrCode = (rq->r_status & S_MASK) + 0x13;
  75. return CriticalError(EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE,
  76. 0, rq->r_status & S_MASK, lpDevice);
  77. }
  78. /* Abort, retry or fail for block devices */
  79. COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice,
  80. int mode)
  81. {
  82. CritErrCode = (rq->r_status & S_MASK) + 0x13;
  83. return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE |
  84. (mode == DSKWRITE ? EFLG_WRITE : 0),
  85. nDrive, rq->r_status & S_MASK, lpDevice);
  86. }