Пример #1
0
static unsigned char normalize_bom_revision(const unsigned char c)
{
	return normalize_rev_id(c);
}
Пример #2
0
static int parse_board_hw_info(unsigned char *buff,
			       board_info_t *bd_info)
{
	char board_name[BOARD_NAME_LEN + 1];
	char vendor_name[VENDOR_NAME_LEN + 1];
	int i;

	hw_info_map_t *p = (hw_info_map_t *)buff;

	if (p->total_bytes != HW_INFO_TOTAL_SIZE) {
		dbg_info("HW Info: The total size isn't correct\n");
		return -1;
	}

	for (i = 0; i < ARRAY_SIZE(board_list); i++) {
		if (strncmp(board_list[i].board_name,
				(const char *)p->board_name,
				strlen(board_list[i].board_name)) == 0)
			break;
	}

	if (i == ARRAY_SIZE(board_list))
		goto fail_to_search_board;

	bd_info->board_type = board_list[i].board_type;
	bd_info->board_id = board_list[i].board_id;

	bd_info->revision_code = normalize_rev_code(p->revision_code);
	if (p->revision_mapping == 'B') {
		bd_info->revision_id = normalize_rev_id_map_b(p->revision_id);
		bd_info->bom_revision = normalize_bom_revision(p->bom_revision);
	} else {
		bd_info->revision_id = normalize_rev_id(p->revision_id);
	}
	bd_info->board_name = board_list[i].board_name;

	for (i = 0; i < ARRAY_SIZE(vendor_list); i++) {
		if (strncmp(vendor_list[i].vendor_name,
				(const char *)p->vendor_name,
				strlen(vendor_list[i].vendor_name)) == 0)
			break;
	}

	if (i == ARRAY_SIZE(vendor_list))
		goto fail_to_search_vendor;

	bd_info->vendor_id = vendor_list[i].vendor_id;
	bd_info->vendor_name = vendor_list[i].vendor_name;

	return 0;

fail_to_search_board:
	for (i = 0; i < BOARD_NAME_LEN; i++)
		board_name[i] = p->board_name[i];
	board_name[i] = 0;

	dbg_info("Failed to parse the board name: %s\n", board_name);

	return -1;

fail_to_search_vendor:
	for (i = 0; i < VENDOR_NAME_LEN; i++)
		vendor_name[i] = p->vendor_name[i];
	vendor_name[i] = 0;

	dbg_info("Failed to parse the vendor name: %s\n", vendor_name);

	return -1;
}
Пример #3
0
static int get_board_info(unsigned char *buffer,
				unsigned char bd_sn,
				struct board_info *bd_info)
{
	int i;
	char tmp[20];
	struct one_wire_info one_wire;
	struct one_wire_info *p = &one_wire;
	unsigned char *pbuf = buffer;

	char *boardname;
	char *vendorname;

	p->total_bytes = (unsigned char)*pbuf;

	pbuf = buffer + 1;
	for (i = 0; i < VENDOR_NAME_LEN; i++)
		p->vendor_name[i] = *pbuf++;

	pbuf = buffer + 11;
	for (i = 0; i < VENDOR_COUNTRY_LEN; i++)
		p->vendor_country[i] = *pbuf++;

	pbuf = buffer + 13;
	for (i = 0; i < BOARD_NAME_LEN; i++)
		p->board_name[i] = *pbuf++;

	p->year = *pbuf++;
	p->week = *pbuf++;
	p->revision_code = *pbuf++;
	p->revision_id = *pbuf++;
	p->bom_revision = *pbuf++;
	p->revision_mapping = *pbuf++;

	memset(tmp, 0, sizeof(tmp));

	for (i = 0; i < BOARD_NAME_LEN; i++) {
		if (p->board_name[i] == 0x20)
			break;

		tmp[i] = p->board_name[i];
	}

	for (i = 0; i < ARRAY_SIZE(board_list); i++) {
		if (strncmp(board_list[i].board_name, tmp,
			strlen(board_list[i].board_name)) == 0) {
			bd_info->board_type = board_list[i].board_type;
			bd_info->board_id = board_list[i].board_id;

			bd_info->revision_code
				= normalize_rev_code(p->revision_code);
			if (p->revision_mapping == 'B') {
				bd_info->revision_id
					= normalize_rev_id_map_b(p->revision_id);
				bd_info->bom_revision
					= normalize_bom_revision(p->bom_revision);
			} else {
				bd_info->revision_id
					= normalize_rev_id(p->revision_id);
			}

			break;
		}
	}

	if (i == ARRAY_SIZE(board_list)) {
		return -1;
	}

	boardname = board_list[i].board_name;

	dbg_loud("board: #%d: boardname: %s\n", bd_sn, boardname);

	memset(tmp, 0, sizeof(tmp));
	for (i = 0; i < VENDOR_NAME_LEN; i++) {
		if (p->vendor_name[i] == 0x20)
			break;
		tmp[i] = p->vendor_name[i];
	}

	for (i = 0; i < ARRAY_SIZE(vendor_list); i++) {
		if (strncmp(vendor_list[i].vendor_name, tmp,
			    strlen(vendor_list[i].vendor_name)) == 0) {
			bd_info->vendor_id = vendor_list[i].vendor_id;
			break;
		}
	}

	if (i == ARRAY_SIZE(vendor_list)) {
		return -1;
	}

	vendorname = vendor_list[i].vendor_name;

	dbg_loud("board: #%d: vendorname: %s\n", bd_sn, vendorname);

	dbg_info("  #%d", bd_sn);
	if (p->revision_mapping == 'B') {
		dbg_info("  %s [%c%c%c]      %s\n",
				boardname,
				bd_info->revision_code,
				bd_info->revision_id,
				bd_info->bom_revision,
				vendorname);
	} else {
		dbg_info("  %s [%c%c]      %s\n",
				boardname,
				bd_info->revision_code,
				bd_info->revision_id,
				vendorname);
	}

	return 0;
}