summaryrefslogtreecommitdiffstats
path: root/tinySIGCOMP/src/tcomp_nack_codes.h
blob: 76eb33fa02f45b7cf222e9517b8db255b6ddf8d3 (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
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
*	
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO 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 DOUBANGO.
*
*/

/**@file tcomp_nack_codes.h
 * @brief List of NACK codes as per RFC 4077 subclause 3.2.
 *
 */

#ifndef TCOMP_NACKCODES_H
#define TCOMP_NACKCODES_H

/*  0   1   2   3   4   5   6   7
    +---+---+---+---+---+---+---+---+
    | 1   1   1   1   1 | T |   0   |
    +---+---+---+---+---+---+---+---+
    |                               |
    :    returned feedback item     :
    |                               |
    +---+---+---+---+---+---+---+---+
    |         code_len = 0          |
    +---+---+---+---+---+---+---+---+
    | code_len = 0  |  version = 1  |
    +---+---+---+---+---+---+---+---+
    |          Reason Code          |
    +---+---+---+---+---+---+---+---+
    |  OPCODE of failed instruction |
    +---+---+---+---+---+---+---+---+
    |   PC of failed instruction    |
    |                               |
    +---+---+---+---+---+---+---+---+
    |                               |
    : SHA-1 Hash of failed message  :
    |                               |
    +---+---+---+---+---+---+---+---+
    |                               |
    :         Error Details         :
    |                               |
    +---+---+---+---+---+---+---+---+
*/
#define INDEX_NACK_HEADER		0
#define INDEX_NACK_VERSION		(INDEX_NACK_HEADER+ 2)
#define INDEX_NACK_REASON_CODE	(INDEX_NACK_VERSION + 1)
#define INDEX_NACK_OPCODE		(INDEX_NACK_REASON_CODE + 1)
#define INDEX_NACK_PC			(INDEX_NACK_OPCODE + 1)
#define INDEX_NACK_SHA1			(INDEX_NACK_PC + 2)
#define INDEX_NACK_DETAILS		(INDEX_NACK_PC + SHA1HashSize)

/************************************************************************************
* Error								       code							details
*************************************************************************************/
#define NACK_NONE							0				// For internal use only
#define NACK_STATE_NOT_FOUND				1				// State ID (6 - 20 bytes)
#define NACK_CYCLES_EXHAUSTED			    2				// Cycles Per Bit (1 byte)
#define NACK_USER_REQUESTED					3
#define NACK_SEGFAULT						4
#define NACK_TOO_MANY_STATE_REQUESTS		5
#define NACK_INVALID_STATE_ID_LENGTH		6
#define NACK_INVALID_STATE_PRIORITY			7
#define NACK_OUTPUT_OVERFLOW				8
#define NACK_STACK_UNDERFLOW				9
#define NACK_BAD_INPUT_BITORDER				10
#define NACK_DIV_BY_ZERO					11
#define NACK_SWITCH_VALUE_TOO_HIGH			12
#define NACK_TOO_MANY_BITS_REQUESTED		13
#define NACK_INVALID_OPERAND				14
#define NACK_HUFFMAN_NO_MATCH				15
#define NACK_MESSAGE_TOO_SHORT				16
#define NACK_INVALID_CODE_LOCATION			17
#define NACK_BYTECODES_TOO_LARGE			18				// Memory size (2 bytes)
#define NACK_INVALID_OPCODE					19
#define NACK_INVALID_STATE_PROBE			20
#define NACK_ID_NOT_UNIQUE					21				// State ID (6 - 20 bytes)
#define NACK_MULTILOAD_OVERWRITTEN			22
#define NACK_STATE_TOO_SHORT				23				// State ID (6 - 20 bytes)
#define NACK_INTERNAL_ERROR					24
#define NACK_FRAMING_ERROR					25


typedef struct tcomp_nack_desc_s
{
	int32_t code;
	const char* desc;
}
tcomp_nack_desc_t;

static const tcomp_nack_desc_t TCOMP_NACK_DESCRIPTIONS[] =
{
	{ NACK_NONE, "NONE" },
	{ NACK_STATE_NOT_FOUND, "STATE_NOT_FOUND" },
	{ NACK_CYCLES_EXHAUSTED, "CYCLES_EXHAUSTED" },
	{ NACK_USER_REQUESTED, "USER_REQUESTED" },
	{ NACK_SEGFAULT, "SEGFAULT" },
	{ NACK_TOO_MANY_STATE_REQUESTS, "TOO_MANY_STATE_REQUESTS" },
	{ NACK_INVALID_STATE_ID_LENGTH, "INVALID_STATE_ID_LENGTH" },
	{ NACK_INVALID_STATE_PRIORITY, "INVALID_STATE_PRIORITY" },
	{ NACK_OUTPUT_OVERFLOW, "OUTPUT_OVERFLOW" },
	{ NACK_STACK_UNDERFLOW, "STACK_UNDERFLOW" },
	{ NACK_BAD_INPUT_BITORDER, "BAD_INPUT_BITORDER" },
	{ NACK_DIV_BY_ZERO, "DIV_BY_ZERO" },
	{ NACK_SWITCH_VALUE_TOO_HIGH, "SWITCH_VALUE_TOO_HIGH" },
	{ NACK_TOO_MANY_BITS_REQUESTED, "TOO_MANY_BITS_REQUESTED" },
	{ NACK_INVALID_OPERAND, "INVALID_OPERAND" },
	{ NACK_HUFFMAN_NO_MATCH, "HUFFMAN_NO_MATCH" },
	{ NACK_MESSAGE_TOO_SHORT, "MESSAGE_TOO_SHORT" },
	{ NACK_INVALID_CODE_LOCATION, "INVALID_CODE_LOCATION" },
	{ NACK_BYTECODES_TOO_LARGE, "BYTECODES_TOO_LARGE" },
	{ NACK_INVALID_OPCODE, "INVALID_OPCODE" },
	{ NACK_INVALID_STATE_PROBE, "INVALID_STATE_PROBE" },
	{ NACK_ID_NOT_UNIQUE, "ID_NOT_UNIQUE" },
	{ NACK_MULTILOAD_OVERWRITTEN, "MULTILOAD_OVERWRITTEN" },
	{ NACK_STATE_TOO_SHORT, "STATE_TOO_SHORT" },
	{ NACK_INTERNAL_ERROR, "INTERNAL_ERROR" },
	{ NACK_FRAMING_ERROR, "FRAMING_ERROR" }
};

#endif /* TCOMP_NACKCODES_H */
OpenPOWER on IntegriCloud