~ubuntu-branches/ubuntu/saucy/biosdevname/saucy-proposed

« back to all changes in this revision

Viewing changes to src/dmidecode/dmioem.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-02-23 17:58:36 UTC
  • Revision ID: james.westby@ubuntu.com-20110223175836-4f0cbcno9zm0lmdu
Tags: upstream-0.3.7
ImportĀ upstreamĀ versionĀ 0.3.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Decoding of OEM-specific entries
 
3
 * This file is part of the dmidecode project.
 
4
 *
 
5
 *   (C) 2007 Jean Delvare <khali@linux-fr.org>
 
6
 *
 
7
 *   This program is free software; you can redistribute it and/or modify
 
8
 *   it under the terms of the GNU General Public License as published by
 
9
 *   the Free Software Foundation; either version 2 of the License, or
 
10
 *   (at your option) any later version.
 
11
 *
 
12
 *   This program is distributed in the hope that it will be useful,
 
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *   GNU General Public License for more details.
 
16
 *
 
17
 *   You should have received a copy of the GNU General Public License
 
18
 *   along with this program; if not, write to the Free Software
 
19
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
20
 */
 
21
 
 
22
#include <stdio.h>
 
23
#include <string.h>
 
24
 
 
25
#include "types.h"
 
26
#include "dmidecode.h"
 
27
#include "dmioem.h"
 
28
#include "../pci.h"
 
29
 
 
30
/*
 
31
 * Globals for vendor-specific decodes
 
32
 */
 
33
 
 
34
enum DMI_VENDORS { VENDOR_UNKNOWN, VENDOR_HP };
 
35
 
 
36
static enum DMI_VENDORS dmi_vendor=VENDOR_UNKNOWN;
 
37
 
 
38
/*
 
39
 * Remember the system vendor for later use. We only actually store the
 
40
 * value if we know how to decode at least one specific entry type for
 
41
 * that vendor.
 
42
 */
 
43
void dmi_set_vendor(const char *s)
 
44
{
 
45
        if(strcmp(s, "HP")==0)
 
46
                dmi_vendor=VENDOR_HP;
 
47
}
 
48
 
 
49
/*
 
50
 * HP-specific data structures are decoded here.
 
51
 *
 
52
 * Code contributed by John Cagle.
 
53
 */
 
54
 
 
55
static int dmi_decode_hp(struct dmi_header *h, const struct libbiosdevname_state *state)
 
56
{
 
57
        u8 *data=h->data;
 
58
        int nic, ptr;
 
59
        u8 smbios_type = 0;
 
60
        u8 bus, device, func;
 
61
        struct pci_device *pdev;
 
62
 
 
63
        switch(h->type)
 
64
        {
 
65
                case 209:
 
66
                case 221:
 
67
                        /*
 
68
                         * Vendor Specific: HP ProLiant NIC MAC Information
 
69
                         *
 
70
                         * This prints the BIOS NIC number,
 
71
                         * PCI bus/device/function, and MAC address
 
72
                         */
 
73
                        if (h->type == 221)
 
74
                                smbios_type=0;
 
75
                        else
 
76
                                smbios_type=0x05;
 
77
 
 
78
                        nic=1;
 
79
                        ptr=4;
 
80
                        while(h->length>=ptr+8)
 
81
                        {
 
82
                                bus = data[ptr+1];
 
83
                                device = data[ptr]>>3;
 
84
                                func = data[ptr]&7;
 
85
                                pdev = find_pci_dev_by_pci_addr(state, 0, bus, device, func);
 
86
                                if (pdev) {
 
87
                                        if((data[ptr]==0x00 && data[ptr+1]==0x00) ||
 
88
                                           (data[ptr]==0xFF && data[ptr+1]==0xFF))
 
89
                                                pdev->smbios_enabled = 0;
 
90
                                        else {
 
91
                                                pdev->smbios_enabled = 1;
 
92
                                                pdev->smbios_type = smbios_type;
 
93
                                                pdev->smbios_instance = nic;
 
94
                                                pdev->physical_slot = 0;
 
95
                                        }
 
96
                                }
 
97
                                nic++;
 
98
                                ptr+=8;
 
99
                        }
 
100
                        break;
 
101
 
 
102
                default:
 
103
                        return 0;
 
104
        }
 
105
        return 1;
 
106
}
 
107
 
 
108
/*
 
109
 * Dispatch vendor-specific entries decoding
 
110
 * Return 1 if decoding was successful, 0 otherwise
 
111
 */
 
112
int dmi_decode_oem(struct dmi_header *h, const struct libbiosdevname_state *state)
 
113
{
 
114
        switch(dmi_vendor)
 
115
        {
 
116
                case VENDOR_HP:
 
117
                        return dmi_decode_hp(h, state);
 
118
                default:
 
119
                        return 0;
 
120
        }
 
121
}