aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt/grt-errors.ads
blob: 974ef382000ae833167dd54f1dba642d6bf8b10c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
--  GHDL Run Time (GRT) - Error handling.
--  Copyright (C) 2002 - 2014 Tristan Gingold
--
--  GHDL is free software; you can redistribute it and/or modify it under
--  the terms of the GNU General Public License as published by the Free
--  Software Foundation; either version 2, or (at your option) any later
--  version.
--
--  GHDL is distributed in the hope that it will be useful, but WITHOUT ANY
--  WARRANTY; without even the implied warranty of MERCHANTABILITY or
--  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
--  for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with GCC; see the file COPYING.  If not, write to the Free
--  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
--  02111-1307, USA.
--
--  As a special exception, if other files instantiate generics from this
--  unit, or you link this unit with other files to produce an executable,
--  this unit does not by itself cause the resulting executable to be
--  covered by the GNU General Public License. This exception does not
--  however invalidate any other reasons why the executable file might be
--  covered by the GNU Public License.
with Grt.Types; use Grt.Types;
with Grt.Hooks;

package Grt.Errors is
   pragma Preelaborate (Grt.Errors);

   --  Multi-call error procedure.
   --  Start and continue with Error_C, finish by an Error_E.
   procedure Error_C (Str : String);
   procedure Error_C (N : Integer);
   procedure Error_C (Str : Ghdl_C_String);
   procedure Error_C_Std (Str : Std_String_Uncons);
   --procedure Error_C (Inst : Ghdl_Instance_Name_Acc);
   procedure Error_E (Str : String := "");
   pragma No_Return (Error_E);

   --  Multi-call report procedure.  Do not exit at end.
   procedure Report_H (Str : String := "");
   procedure Report_C (Str : Ghdl_C_String);
   procedure Report_C (Str : String);
   procedure Report_C (N : Integer);
   procedure Report_Now_C;
   procedure Report_E (Str : String);
   procedure Report_E (Str : Std_String_Ptr);
   procedure Report_E (N : Integer);

   --  Complete error message.
   procedure Error (Str : String);
   pragma No_Return (Error);

   --  Warning message.
   procedure Warning (Str : String);

   --  Internal error.  The message must contain the subprogram name which
   --  has called this procedure.
   procedure Internal_Error (Msg : String);
   pragma No_Return (Internal_Error);

   --  Display a message which is not an error.
   procedure Info (Str : String);

   --  Backtrace used to report call stack in case of error.
   --  Note: for simplicity we assume that a PC is enough to display the
   --  corresponding file name, line number and routine name.  Might not be
   --  true on some platforms.
   --  There is a C version of this record in grt_itf.h
   type Integer_Address_Array is array (Natural range <>) of Integer_Address;
   type Backtrace_Addrs is record
      Size : Natural;
      Skip : Natural;
      Addrs : Integer_Address_Array (0 .. 31);
   end record;
   pragma Convention (C, Backtrace_Addrs);

   type Backtrace_Addrs_Acc is access Backtrace_Addrs;

   --  Save the current backtrace to BT, but skip SKIP frame.  0 means that
   --  the caller of this procedure will be in the backtrace.
   procedure Save_Backtrace (Bt : out Backtrace_Addrs; Skip : Natural);
   pragma Import (C, Save_Backtrace, "grt_save_backtrace");

   --  Finish error message with a call stack.
   procedure Error_E_Call_Stack (Bt : Backtrace_Addrs);
   pragma No_Return (Error_E_Call_Stack);

   procedure Error_E_Call_Stack (Bt : Backtrace_Addrs_Acc);
   pragma No_Return (Error_E_Call_Stack);

   --  Display an error message for an overflow.
   procedure Grt_Overflow_Error (Bt : Backtrace_Addrs_Acc);
   pragma No_Return (Grt_Overflow_Error);

   --  Display an error message for a NULL access dereference.
   procedure Grt_Null_Access_Error (Bt : Backtrace_Addrs_Acc);
   pragma No_Return (Grt_Null_Access_Error);

   --  Called at end of error message.  Central point for failures.
   procedure Fatal_Error;
   pragma No_Return (Fatal_Error);
   pragma Export (C, Fatal_Error, "__ghdl_fatal");

   --  Stop or finish simulation (for VHPI or std.env).
   Exit_Status : Integer := 0;
   procedure Exit_Simulation;

   --  Simulation status,
   --  Runtime error.
   Run_Error : constant Integer := -1;
   --  No process has been run.
   Run_None : constant Integer := 1;
   --  At least one process was run.
   Run_Resumed : constant Integer := 2;
   --  Simulation is finished.
   Run_Finished : constant Integer := 3;
   --  Stop/finish request from user (via std.env).
   Run_Stop : constant Integer := 4;

   --  Hook called in case of error.
   Error_Hook : Grt.Hooks.Proc_Hook_Type := null;

   --  If true, an error is expected and the exit status is inverted.
   Expect_Failure : Boolean := False;

   --  Internal subprograms, to be called only by the symbolizer.
   procedure Put_Err (C : Character);
   procedure Put_Err (Str : String);
   procedure Put_Err (Str : Ghdl_C_String);
   procedure Put_Err (N : Integer);
   procedure Newline_Err;
private
   pragma Export (C, Grt_Overflow_Error, "grt_overflow_error");
   pragma Export (C, Grt_Null_Access_Error, "grt_null_access_error");
end Grt.Errors;
setPinInputHigh(A6); setPinInputHigh(A7); setPinInputHigh(A8); setPinInputHigh(A9); setPinInputHigh(A10); setPinInputHigh(B3); setPinInputHigh(B4); setPinInputHigh(B5); setPinInputHigh(B6); setPinInputHigh(B7); setPinInputHigh(B8); setPinInputHigh(B9); setPinInputHigh(B11); setPinInputHigh(B12); setPinInputHigh(B13); setPinInputHigh(B14); setPinInputHigh(B15); memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); matrix_init_quantum(); osalSysLock(); enable_input_events(); osalSysUnlock(); } uint8_t matrix_scan(void) { switch_buffer = ((uint32_t)(porta_buffer & 0x7FF)) | ((uint32_t)(portb_buffer & 0x3F8) << 8); switch (switch_buffer) { case 0x1134E: matrix[0] = 0x01; break; case 0x3774D: matrix[0] = 0x02; break; case 0x10BCC: matrix[0] = 0x04; break; case 0x16B4B: matrix[0] = 0x08; break; case 0x167CA: matrix[0] = 0x10; break; case 0x35FC9: matrix[0] = 0x20; break; case 0x15B48: matrix[0] = 0x40; break; case 0x28347: matrix[0] = 0x80; break; case 0x173C6: matrix[0] = 0x100; break; case 0x143CF: matrix[0] = 0x200; break; case 0x3FDC5: matrix[0] = 0x400; break; case 0x3FD21: matrix[0] = 0x800; break; case 0x3FD77: matrix[0] = 0x1000; break; case 0x3FD72: matrix[0] = 0x2000; break; //Special pin case 0x3E7FA: matrix[0] = 0x8000; break; case 0x183EE: matrix[0] = 0x10000; break; case 0x197F3: matrix[0] = 0x20000; break; case 0x1AB7E: matrix[0] = 0x40000; break; case 0x107C3: matrix[1] = 0x01; break; case 0x3FD2E: matrix[1] = 0x02; break; case 0x3FD28: matrix[1] = 0x04; break; case 0x3FD3A: matrix[1] = 0x08; break; case 0x3FD2D: matrix[1] = 0x10; break; case 0x3FD2B: matrix[1] = 0x20; break; case 0x3FDA5: matrix[1] = 0x40; break; case 0x3FDAA: matrix[1] = 0x80; break; case 0x3FD36: matrix[1] = 0x100; break; case 0x3FD30: matrix[1] = 0x200; break; case 0x3FDAF: matrix[1] = 0x400; break; case 0x3FD22: matrix[1] = 0x800; break; case 0x157D4: matrix[1] = 0x1000; break; //Does not exist in matrix //Special pin case 0x1C778: matrix[1] = 0x8000; break; case 0x387ED: matrix[1] = 0x10000; break; case 0x19B74: matrix[1] = 0x20000; break; case 0x3FD7D: matrix[1] = 0x40000; break; //Special pin case 0x3FDBE: matrix[2] = 0x02; break; case 0x3FDAC: matrix[2] = 0x04; break; case 0x3FDBB: matrix[2] = 0x08; break; case 0x3FD39: matrix[2] = 0x10; break; case 0x3FDB8: matrix[2] = 0x20; break; case 0x3FDB7: matrix[2] = 0x40; break; case 0x3FD35: matrix[2] = 0x80; break; case 0x3FDB4: matrix[2] = 0x100; break; case 0x3FD33: matrix[2] = 0x200; break; case 0x3FDA3: matrix[2] = 0x400; break; case 0x3FD24: matrix[2] = 0x800; break; case 0x0FFDB: matrix[2] = 0x1000; break; case 0x3FDF5: matrix[2] = 0x2000; break; case 0x3FDFF: matrix[2] = 0x4000; break; case 0x3C3E4: matrix[2] = 0x8000; break; case 0x38B6C: matrix[2] = 0x10000; break; case 0x39FF6: matrix[2] = 0x20000; break; case 0x3FDFC: matrix[2] = 0x40000; break; //Special pin case 0x3FDA6: matrix[3] = 0x02; break; case 0x3FD27: matrix[3] = 0x04; break; case 0x3FD3C: matrix[3] = 0x08; break; case 0x3FDA9: matrix[3] = 0x10; break; case 0x3FDBD: matrix[3] = 0x20; break; case 0x3FDB1: matrix[3] = 0x40; break; case 0x3FDB2: matrix[3] = 0x80; break; case 0x30353: matrix[3] = 0x100; break; case 0x37BD1: matrix[3] = 0x200; break; case 0x363D2: matrix[3] = 0x400; break; case 0x3FD5F: matrix[3] = 0x800; break; //Does not exist in matrix //Does not exist in matrix //Special pin case 0x1BF00: matrix[3] = 0x8000; break; case 0x18FEB: matrix[3] = 0x10000; break; case 0x3FF69: matrix[3] = 0x20000; break; case 0x3A37B: matrix[3] = 0x40000; break; default: if ((portb_buffer & 0x1000) == 0) { matrix[1] = 0x4000; break; } if ((portb_buffer & 0x2000) == 0) { matrix[3] = 0x4000; break; } if ((portb_buffer & 0x4000) == 0) { matrix[0] = 0x4000; break; } if ((portb_buffer & 0x8000) == 0) { matrix[2] = 0x01; break; } matrix[0] = 0x00; matrix[1] = 0x00; matrix[2] = 0x00; matrix[3] = 0x00; } //Special case for Shift if (readPin(B11) == 0) { matrix[3] |= 0x01; } porta_buffer = 65535; portb_buffer = 65535; matrix_scan_quantum(); return 1; } matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } void matrix_print(void) { } __attribute__ ((weak)) void matrix_init_kb(void) { matrix_init_user(); } __attribute__ ((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } __attribute__ ((weak)) void matrix_init_user(void) { } __attribute__ ((weak)) void matrix_scan_user(void) { }