+
+ /* com/agilent/rmc/amr/AmrMaster.class
+ * com/agilent/rmc/mgui/RmcPanel.class
+ * com/agilent/rmc/mgui/panels/AvrManualConfig.class
+ * com/agilent/rmc/mgui/panels/CardConf.jad
+ * com/agilent/rmc/mgui/panels/PowerMgmtConf.jad
+ * com/agilent/rmc/mgui/panels/RemoteDiskConf.jad
+ */
+ printf("\tserial1Present\t\t: %s\n", BD_TEXT(bd, SERIAL1));
+ printf("\ticmbPresent\t\t: %s\n", BD_TEXT(bd, ICMB));
+ printf("\tlanPresent\t\t: %s\n", BD_TEXT(bd, LAN));
+ printf("\tserial2Present\t\t: %s\n", BD_TEXT(bd, SERIAL2));
+ printf("\tserial3Present\t\t: %s\n", BD_TEXT(bd, SERIAL3));
+ printf("\tusbPresent\t\t: %s\n", BD_TEXT(bd, USB));
+ printf("\tpciPresent\t\t: %s\n", BD_TEXT(bd, PCI));
+ printf("\tlpcPresent\t\t: %s\n", BD_TEXT(bd, LPC));
+ printf("\tvgaPresent\t\t: %s\n", BD_TEXT(bd, VGA));
+ printf("\tbatteryPresent\t\t: %s\n", BD_TEXT(bd, BATTERY));
+ printf("\tacdcPresent\t\t: %s\n", BD_TEXT(bd, ACDC));
+ printf("\tstandbyPresent\t\t: %s\n", BD_TEXT(bd, STANDBY));
+ printf("\thasPowerConnectors\t: %s\n", BD_TEXT(bd, POWERCONN));
+ printf("\tdviPresent\t\t: %s\n", BD_TEXT(bd, DVI));
+ printf("\tpowerSwitchATX\t\t: %s\n", BD_TEXT(bd, PWRATX));
+ printf("\tpowerSwitchRelay\t: %s\n", BD_TEXT(bd, PWRRELAY));
+ /* 22 & 4 */
+ printf("\tps2aPresent\t\t: %s\n", BD_TEXT(bd, PS2A));
+}
+
+void handle_boarddescription(unsigned char *fw, int len, int patch)
+{
+ struct file_entry *fent;
+ unsigned char *pos;
+
+ for (fent = get_next_file(fw, len); fent != NULL; fent = get_next_file(NULL, 0)) {
+ if (!strcmp(fent->name, "pdata"))
+ break;
+ }
+
+ if (fent == NULL) {
+ fprintf(stderr, "pdata file not found, aborting!\n");
+ exit(1);
+ }
+
+
+ pos = fent->start;
+ /* MAGIC? */
+ if (*((unsigned int*)pos) != 0x00002802) {
+ fprintf(stderr, "pdata magic does not match, aborting!\n");
+ exit(1);
+ }
+
+ pos += 26;
+
+ /* MAGIC2? */
+ if (*((unsigned int*)pos) != 0x00500101) {
+ fprintf(stderr, "pdata magic2 does not match, aborting!\n");
+ exit(1);
+ }
+
+ if (patch) {
+ /* Enable ATX and relay power switching */
+ BD_SET(pos, PWRATX);
+ BD_SET(pos, PWRRELAY);
+ }
+
+ printf("0x%08x: BOARD_DESCRIPTION: ", fent->start - fw);
+ print_boarddescription(pos);
+}
+
+void syntax(char *name)
+{
+ fprintf(stderr,"Syntax: %s parameters firmware.bin\n", name);
+ fprintf(stderr,"parameters as follows:\n");
+ fprintf(stderr,"\t-d\t\tdisplay all properties of the image\n");
+ fprintf(stderr,"\t-u\t\tupdate checksum of the image\n");
+ fprintf(stderr,"\t-b\t\tmodify BOARD_DESCRIPTION for more power-switch options\n");
+ fprintf(stderr,"\t-e\t\textract files in firmware\n");
+ fprintf(stderr,"\t-t property\tset 'property' to true\n");
+ fprintf(stderr,"\t-f property\tset 'property' to false\n");
+ fprintf(stderr,"\t-w property\tallow read-write access to 'property'\n");
+ fprintf(stderr,"\t-r property\tallow read-only access to 'property'\n");
+ exit(1);
+}
+
+void add_action(int opt, char *optarg, struct propaction **paction) {
+ struct propaction *pos = *paction;
+ struct propaction *prev = NULL;
+
+ while (pos != NULL) {
+ if (!strcmp(pos->property, optarg))
+ break;
+ prev = pos;
+ pos = pos->next;
+ }
+
+ if (pos == NULL) {
+ pos = malloc(sizeof(struct propaction));
+ if (pos == NULL) {
+ perror("malloc");
+ exit(1);
+ }
+ bzero(pos, sizeof(struct propaction));
+ pos->property = optarg;
+
+ if (prev == NULL) {
+ *paction = pos;
+ } else {
+ prev->next = pos;
+ }
+ }
+
+ switch(opt) {
+ case 't':
+ if (pos->action & PROP_ACTION_FALSE) {
+ fprintf(stderr,"inconsistent requests for %s\n",pos->property);
+ exit(1);
+ }
+ pos->action |= PROP_ACTION_TRUE;
+ break;
+ case 'f':
+ if (pos->action & PROP_ACTION_TRUE) {
+ fprintf(stderr,"inconsistent requests for %s\n",pos->property);
+ exit(1);
+ }
+ pos->action |= PROP_ACTION_FALSE;
+ break;
+ case 'w':
+ if (pos->action & PROP_ACTION_RO) {
+ fprintf(stderr,"inconsistent requests for %s\n",pos->property);
+ exit(1);
+ }
+ pos->action |= PROP_ACTION_RW;
+ break;
+ case 'r':
+ if (pos->action & PROP_ACTION_RW) {
+ fprintf(stderr,"inconsistent requests for %s\n",pos->property);
+ exit(1);
+ }
+ pos->action |= PROP_ACTION_RO;
+ break;
+ }
+}
+
+int check_crc(unsigned char *fw, int len)
+{
+ int ret;
+ unsigned int crc, oldcrc;
+
+ ret = rsb_crc2(fw, len, 0x55335053, &crc);
+ oldcrc = (unsigned int)*((unsigned int*)(fw + len - 4));
+
+ printf("Checksum: 0x%08x (%s), should be: 0x%08x\n",
+ crc,
+ (ret ? "NOT OK" : "OK"),
+ oldcrc);
+
+ return ret;
+}
+
+void check_image(unsigned char *fw, int len)
+{
+ struct file_entry *fent;
+ char *last_name = NULL;
+
+ /* get_next_file will abort on error */
+ fent = get_next_file(fw, len);
+ while (fent != NULL) {
+ last_name = fent->name;
+ fent = get_next_file(NULL, 0);
+ }