summaryrefslogtreecommitdiff
path: root/tools/d2c/bits/manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/d2c/bits/manager.c')
-rw-r--r--tools/d2c/bits/manager.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/tools/d2c/bits/manager.c b/tools/d2c/bits/manager.c
index 4999680..560bade 100644
--- a/tools/d2c/bits/manager.c
+++ b/tools/d2c/bits/manager.c
@@ -29,6 +29,7 @@
#include <malloc.h>
#include <stdint.h>
#include <string.h>
+#include <unistd.h>
#include "../helpers.h"
@@ -114,6 +115,25 @@ void mark_raw_bitfield_as_used(raw_bitfield *field)
}
+/******************************************************************************
+* *
+* Paramètres : field = champ de bits à traiter. *
+* fd = descripteur d'un flux ouvert en écriture. *
+* *
+* Description : Imprime la désignation d'un champ de bits dans du code. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void write_raw_bitfield(const raw_bitfield *field, int fd)
+{
+ dprintf(fd, "raw_%s", field->name);
+
+}
+
@@ -294,13 +314,30 @@ raw_bitfield *find_named_field_in_bits(const coding_bits *bits, const char *name
* *
******************************************************************************/
-bool declare_used_bits_fields(const coding_bits *bits, int fd, unsigned int wide)
+bool declare_used_bits_fields(const coding_bits *bits, int fd)
{
+ unsigned int wide; /* Taille des mots */
size_t i; /* Boucle de parcours */
+ off_t start; /* Point de départ dans le code*/
+ off_t end; /* Point d'arrivée dans le code*/
+
+ wide = count_coded_bits(bits);
for (i = 0; i < bits->bf_count; i++)
if (bits->fields[i].used)
- dprintf(fd, "\t\tuint%u_t raw_%s;\n", wide, bits->fields[i].name);
+ {
+ start = lseek(fd, 0, SEEK_CUR);
+
+ dprintf(fd, "\tuint%u_t ", wide);
+ write_raw_bitfield(&bits->fields[i], fd);
+ dprintf(fd, ";");
+
+ end = lseek(fd, 0, SEEK_CUR);
+
+ dprintf(fd, "%*s", 42 - (int)(end - start), "/");
+ dprintf(fd, "* Champ brut à décoder */\n");
+
+ }
return true;
@@ -325,22 +362,22 @@ bool check_bits_correctness(const coding_bits *bits, int fd)
switch (bits->curpos)
{
case 8:
- dprintf(fd, "\t\tif ((raw & 0x%" PRIx8 ") != 0x%" PRIx8 ") return NULL;\n",
+ dprintf(fd, "\tif ((raw & 0x%" PRIx8 ") != 0x%" PRIx8 ") return NULL;\n",
(uint8_t)bits->mask, (uint8_t)bits->bits);
break;
case 16:
- dprintf(fd, "\t\tif ((raw & 0x%" PRIx16 ") != 0x%" PRIx16 ") return NULL;\n",
+ dprintf(fd, "\tif ((raw & 0x%" PRIx16 ") != 0x%" PRIx16 ") return NULL;\n",
(uint16_t)bits->mask, (uint16_t)bits->bits);
break;
case 32:
- dprintf(fd, "\t\tif ((raw & 0x%" PRIx32 ") != 0x%" PRIx32 ") return NULL;\n",
+ dprintf(fd, "\tif ((raw & 0x%" PRIx32 ") != 0x%" PRIx32 ") return NULL;\n",
(uint32_t)bits->mask, (uint32_t)bits->bits);
break;
case 64:
- dprintf(fd, "\t\tif ((raw & 0x%" PRIx64 ") != 0x%" PRIx64 ") return NULL;\n",
+ dprintf(fd, "\tif ((raw & 0x%" PRIx64 ") != 0x%" PRIx64 ") return NULL;\n",
bits->mask, bits->bits);
break;
@@ -377,7 +414,9 @@ bool define_used_bits_fields(const coding_bits *bits, int fd)
rf = &bits->fields[i];
if (!rf->used) continue;
- dprintf(fd, "\t\traw_%s = (_raw >> %u) & 0x%llx;\n", rf->name, rf->start, (1ull << rf->length) - 1);
+ dprintf(fd, "\t");
+ write_raw_bitfield(rf, fd);
+ dprintf(fd, " = (raw >> %u) & 0x%llx;\n", rf->start, (1ull << rf->length) - 1);
got_one = true;