blob: ea568aebf7fe7611e75c61fd071f19cb1db33cfc [file] [log] [blame]
robbiewa6d58a12003-07-02 18:43:40 +00001/* -*- linux-c -*-
2 *
3 * Copyright (c) 2003 by Intel Corp.
4 *
5 * This program is distributed in the hope that it will be useful,
6 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
8 * file and program are licensed under a BSD style license. See
9 * the Copying file included with the OpenHPI distribution for
10 * full licensing terms.
11 *
12 * Authors:
13 * Kevin Gao <kevin.gao@intel.com>
14 */
15
16#include <stdio.h>
17#include <hpitest.h>
18
19int process_domain_eventlog(SaHpiSessionIdT session_id)
20{
21 SaHpiSelEntryIdT prev_entry_id;
22 SaHpiSelEntryIdT next_entry_id;
23 SaHpiSelEntryIdT current_entry_id;
24 SaHpiSelEntryT eventlog_entry;
25 SaHpiRdrT rdr;
26 SaHpiRptEntryT rpt_entry1;
27 SaErrorT val;
28 int ret = HPI_TEST_PASS;
29
robbiewd9972f62003-07-15 21:03:30 +000030 prev_entry_id = SAHPI_NEWEST_ENTRY;
robbiewa6d58a12003-07-02 18:43:40 +000031 while (next_entry_id != SAHPI_NO_MORE_ENTRIES) {
32 current_entry_id = prev_entry_id;
33 val = saHpiEventLogEntryGet(session_id,
34 SAHPI_DOMAIN_CONTROLLER_ID, current_entry_id,
35 &prev_entry_id, &next_entry_id, &eventlog_entry,
36 &rdr, &rpt_entry1);
37 if (val != SA_OK) {
38 printf(" Does not conform the expected behaviors!\n");
39 printf(" Retrieve the prev event log entry failed!\n");
40 printf(" Return value: %s\n", get_error_string(val));
41 ret = HPI_TEST_FAIL;
42 goto out;
43 }
44 }
45
46out:
47 return ret;
48}
49
50int process_resource(SaHpiSessionIdT session_id, SaHpiRptEntryT rpt_entry, callback2_t func)
51{
52 SaHpiResourceIdT resource_id = rpt_entry.ResourceId;
53 SaHpiSelEntryIdT prev_entry_id;
54 SaHpiSelEntryIdT next_entry_id;
55 SaHpiSelEntryIdT current_entry_id;
56 SaHpiSelEntryT eventlog_entry;
57 SaHpiRdrT rdr;
58 SaHpiRptEntryT rpt_entry1;
59 SaErrorT val;
60 int ret = HPI_TEST_PASS;
61
62 if (rpt_entry.ResourceCapabilities & SAHPI_CAPABILITY_SEL) {
63 next_entry_id = SAHPI_NEWEST_ENTRY;
64 while (next_entry_id != SAHPI_NO_MORE_ENTRIES) {
65 current_entry_id = prev_entry_id;
66 val = saHpiEventLogEntryGet(session_id, resource_id,
67 current_entry_id, &prev_entry_id,
68 &next_entry_id, &eventlog_entry,
69 &rdr, &rpt_entry1);
70 if (val != SA_OK) {
71 printf(" Does not conform the expected behaviors!\n");
72 printf(" Retrieve the prev event log entry failed!\n");
73 printf(" Return value: %s\n", get_error_string(val));
74 ret = HPI_TEST_FAIL;
75 goto out;
76 }
77 }
78 }
79
80out:
81 return ret;
82}
83
84int main()
85{
86 SaHpiVersionT version;
87 SaErrorT val;
88 int ret = HPI_TEST_PASS;
89
90 val = saHpiInitialize(&version);
91 if (val != SA_OK) {
92 printf(" Function \"saHpiInitialize\" works abnormally!\n");
93 printf(" Cannot initialize HPI!\n");
94 printf(" Return value: %s\n", get_error_string(val));
95 ret = HPI_TEST_FAIL;
96 goto out;
97 }
98
99 ret = process_domain(SAHPI_DEFAULT_DOMAIN_ID, process_resource, NULL,
100 process_domain_eventlog);
101
102 val = saHpiFinalize();
103 if (val != SA_OK) {
104 printf(" Function \"saHpiFinalize\" works abnormally!\n");
105 printf(" Cannot cleanup HPI");
106 printf(" Return value: %s\n", get_error_string(val));
107 ret = HPI_TEST_FAIL;
108 }
109
110out:
111 return ret;
112}