Patchwork superiotool: generation from C code to XML

login
register
about
Submitter Антон Кочков
Date 2011-02-14 21:02:45
Message ID <AANLkTinRb7OUmZomZmkN0Nwb1won19ZRsiz_Z_YeG2uB@mail.gmail.com>
Download mbox | patch
Permalink /patch/2642/
State New
Headers show

Comments

Антон Кочков - 2011-02-14 21:02:45
superiotool: add support for producing xml files from C code

Signed-off-by: Anton Kochkov <anton.kochkov@gmail.com>
---
Stefan Reinauer - 2011-02-15 00:06:36
* Антон Кочков <anton.kochkov@gmail.com> [110214 22:02]:
> superiotool: add support for producing xml files from C code
> 
> Signed-off-by: Anton Kochkov <anton.kochkov@gmail.com>

Is it possible to make superiotool read those instead of the C
structures as its database?

Patch

Index: util/superiotool/export_sio.c
===================================================================
--- util/superiotool/export_sio.c	(revision 0)
+++ util/superiotool/export_sio.c	(revision 0)
@@ -0,0 +1,247 @@ 
+/*
+ * This file is part of the superiotool project.
+ *
+ * Copyright (C) Anton Kochkov <anton.kochkov@gmail.com>
+ *
+ * This program 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 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include "superiotool.h"
+#include <stdio.h>
+
+struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device) {
+	return NULL;
+}
+
+uint8_t pci_read_byte(struct pci_dev *pci_device, uint16_t addr) {
+	return 0;
+}
+
+void pci_write_byte(struct pci_dev *pci_device, uint16_t addr, uint8_t data) {}
+
+int verbose = 0;
+int chip_found = 0;
+int extra_dump = 0;
+
+uint8_t regval(uint16_t port, uint8_t reg) { return 0; }
+void regwrite(uint16_t port, uint8_t reg, uint8_t val) {}
+void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port){}
+void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port){}
+void enter_conf_mode_fintek_7777(uint16_t port){}
+void exit_conf_mode_fintek_7777(uint16_t port){}
+int superio_unknown(const struct superio_registers reg_table[], uint16_t id){return 0;}
+const char *get_superio_name(const struct superio_registers reg_table[], uint16_t id){return NULL;}
+void dump_superio(const char *name, const struct superio_registers reg_table[],
+           uint16_t port, uint16_t id, uint8_t ldn_sel){}
+void dump_io(uint16_t iobase, uint16_t length){}
+void probing_for(const char *vendor, const char *info, uint16_t port){}
+void print_vendor_chips(const char *vendor, const struct superio_registers reg_table[]){}
+/* ali.c */
+#ifndef ALI
+void probe_idregs_ali(uint16_t port){}
+void print_ali_chips(void){}
+#endif
+/* fintek.c */
+#ifndef FINTEK
+void probe_idregs_fintek(uint16_t port){}
+void probe_idregs_fintek_alternative(uint16_t port){}
+void print_fintek_chips(void){}
+#endif
+/* ite.c */
+#ifndef ITE
+void probe_idregs_ite(uint16_t port){}
+void print_ite_chips(void){}
+#endif
+/* nsc.c */
+#ifndef NSC
+void probe_idregs_nsc(uint16_t port){}
+void print_nsc_chips(void){}
+#endif
+/* nuvoton.c */
+#ifndef NUOVOTON
+void probe_idregs_nuvoton(uint16_t port){}
+void print_nuvoton_chips(void){}
+#endif
+/* smsc.c */
+#ifndef SMSC
+void probe_idregs_smsc(uint16_t port){}
+void print_smsc_chips(void){}
+#endif
+/* winbond.c */
+#ifndef WINBOND
+void probe_idregs_winbond(uint16_t port){}
+void print_winbond_chips(void){}
+#endif
+/* via.c */
+#ifndef VIA
+void probe_idregs_via(uint16_t port){}
+void print_via_chips(void){}
+#endif
+
+
+#ifdef ITE
+#include "ite.c"
+#endif
+
+#ifdef FINTEK
+#include "fintek.c"
+#endif
+
+#ifdef WINBOND
+#include "winbond.c"
+#endif
+
+#ifdef SMSC
+#include "smsc.c"
+#endif
+
+#ifdef NSC
+#include "nsc.c"
+#endif
+
+#ifdef NUOVOTON
+#include "nuvoton.c"
+#endif
+
+#ifdef ALI
+#include "ali.c"
+#endif
+
+#ifdef VIA
+#include "via.c"
+#endif
+
+void export_sio(FILE *stream, const struct superio_registers *sioarray, char* name, char* description) {
+	int i = 0, j = 0, k = 0;	
+
+	fprintf(stream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+	fprintf(stream, "<sioarray name=\"%s\" description=\"%s\">\n", name, description);
+
+	i = 0;
+	while (sioarray[i].name != NULL) {
+		fprintf(stream, "<sio model=\"%s\" id=\"0x%x\" >\n", sioarray[i].name, sioarray[i].superio_id);
+		if (sioarray[i].superio_id != EOT) {
+			j = 0;
+			while (sioarray[i].ldn[j].ldn != EOT) {
+				if (sioarray[i].ldn[j].ldn == NOLDN) {
+					fprintf(stream, "<noldn>\n");
+					k = 0;
+					while (k < IDXSIZE) {
+						if ((sioarray[i].ldn[j].idx[k] != 0)&(sioarray[i].ldn[j].idx[k] != EOT)){
+							if (sioarray[i].ldn[j].def[k] != NANA)
+								fprintf(stream, "<reg address=\"0x%x\" default_value=\"0x%x\" />\n", sioarray[i].ldn[j].idx[k], sioarray[i].ldn[j].def[k]);
+							else
+								fprintf(stream, "<reg address=\"0x%x\" default_value=\"NANA\" />\n", sioarray[i].ldn[j].idx[k]);
+						
+						}
+						k++;
+					}
+					fprintf(stream, "</noldn>\n");
+				} else {
+					fprintf(stream, "<ldn number=\"0x%x\" name=\"%s\" description=\"%s\">\n", sioarray[i].ldn[j].ldn, sioarray[i].ldn[j].name, "");
+					k = 0;
+					while (k < IDXSIZE) {
+						if ((sioarray[i].ldn[j].idx[k] != 0)&(sioarray[i].ldn[j].idx[k] != EOT)) {
+							if (sioarray[i].ldn[j].def[k] != NANA)
+								fprintf(stream, "<reg address=\"0x%x\" default_value=\"0x%x\" />\n", sioarray[i].ldn[j].idx[k], sioarray[i].ldn[j].def[k]);
+							else
+								fprintf(stream, "<reg address=\"0x%x\" default_value=\"NANA\" />\n", sioarray[j].ldn[j].idx[k]);
+						}
+						k++;
+					}
+					fprintf(stream, "</ldn>\n");
+				}
+			j++;
+			}
+		}
+		fprintf(stream, "</sio>\n");
+		i++;
+	}
+	fprintf(stream, "</sioarray>\n");		
+}
+
+int main(int argc, char** argv){
+
+	FILE *stream;
+	struct superio_registers *sioarray;
+
+	sioarray = reg_table;
+
+#ifdef ITE
+
+	stream = fopen("ite.sio.xml", "w");
+	export_sio(stream, sioarray, "ite", "ite superios");
+	fclose(stream);
+
+#endif
+
+#ifdef ALI
+
+	stream = fopen("ali.sio.xml", "w");
+	export_sio(stream, sioarray, "ali", "ali superios");
+	fclose(stream);
+
+#endif
+
+#ifdef FINTEK
+
+	stream = fopen("fintek.sio.xml", "w");
+	export_sio(stream, sioarray, "fintek", "fintek superios");
+	fclose(stream);
+
+#endif
+
+#ifdef NSC
+
+	stream = fopen("nsc.sio.xml", "w");
+	export_sio(stream, sioarray, "nsc", "nsc superios");
+	fclose(stream);
+
+#endif
+
+#ifdef NUOVOTON
+
+	stream = fopen("nuovoton.sio.xml", "w");
+	export_sio(stream, sioarray, "nuovoton", "nuovoton superios");
+	fclose(stream);
+
+#endif
+
+#ifdef SMSC
+
+	stream = fopen("smsc.sio.xml", "w");
+	export_sio(stream, sioarray, "smsc", "nuovoton superios");
+	fclose(stream);
+
+#endif
+
+#ifdef VIA
+	
+	stream = fopen("via.sio.xml", "w");
+	export_sio(stream, sioarray, "via", "via superios");
+	fclose(stream);
+
+#endif
+
+#ifdef WINBOND
+
+	stream = fopen("winbond.sio.xml", "w");
+	export_sio(stream, sioarray, "winbond", "winbond superios");
+	fclose(stream);
+
+#endif
+
+	return 0;
+}