2
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2015, 2019 SAP SE. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
26
#include "libodm_aix.hpp"
27
#include "misc_aix.hpp"
31
#include "runtime/arguments.hpp"
32
#include "runtime/os.hpp"
35
dynamicOdm::dynamicOdm() {
36
const char* libodmname = "/usr/lib/libodm.a(shr_64.o)";
38
_libhandle = os::dll_load(libodmname, ebuf, sizeof(ebuf));
41
trcVerbose("Cannot load %s (error %s)", libodmname, ebuf);
44
_odm_initialize = (fun_odm_initialize )dlsym(_libhandle, "odm_initialize" );
45
_odm_set_path = (fun_odm_set_path )dlsym(_libhandle, "odm_set_path" );
46
_odm_mount_class = (fun_odm_mount_class)dlsym(_libhandle, "odm_mount_class");
47
_odm_get_obj = (fun_odm_get_obj )dlsym(_libhandle, "odm_get_obj" );
48
_odm_terminate = (fun_odm_terminate )dlsym(_libhandle, "odm_terminate" );
49
if (!_odm_initialize || !_odm_set_path || !_odm_mount_class || !_odm_get_obj || !_odm_terminate) {
50
trcVerbose("Couldn't find all required odm symbols from %s", libodmname);
51
os::dll_unload(_libhandle);
57
dynamicOdm::~dynamicOdm() {
58
if (_libhandle) { os::dll_unload(_libhandle); }
62
void odmWrapper::clean_data() { if (_data) { free(_data); _data = nullptr; } }
65
int odmWrapper::class_offset(const char *field, bool is_aix_5)
67
assert(has_class(), "initialization");
68
for (int i = 0; i < odm_class()->nelem; i++) {
69
if (strcmp(odm_class()->elem[i].elemname, field) == 0) {
70
int offset = odm_class()->elem[i].offset;
71
if (is_aix_5) { offset += LINK_VAL_OFFSET; }
79
void odmWrapper::determine_os_kernel_version(uint32_t* p_ver) {
80
int major_aix_version = ((*p_ver) >> 24) & 0xFF,
81
minor_aix_version = ((*p_ver) >> 16) & 0xFF;
82
assert(*p_ver, "must be initialized");
84
odmWrapper odm("product", "/usr/lib/objrepos"); // could also use "lpp"
85
if (!odm.has_class()) {
86
trcVerbose("try_determine_os_kernel_version: odm init problem");
89
int voff, roff, moff, foff;
90
bool is_aix_5 = (major_aix_version == 5);
91
voff = odm.class_offset("ver", is_aix_5);
92
roff = odm.class_offset("rel", is_aix_5);
93
moff = odm.class_offset("mod", is_aix_5);
94
foff = odm.class_offset("fix", is_aix_5);
95
if (voff == -1 || roff == -1 || moff == -1 || foff == -1) {
96
trcVerbose("try_determine_os_kernel_version: could not get offsets");
99
if (!odm.retrieve_obj("name='bos.mp64'")) {
100
trcVerbose("try_determine_os_kernel_version: odm_get_obj failed");
103
int version, release, modification, fix_level;
105
version = odm.read_short(voff);
106
release = odm.read_short(roff);
107
modification = odm.read_short(moff);
108
fix_level = odm.read_short(foff);
109
trcVerbose("odm found version: %d.%d.%d.%d", version, release, modification, fix_level);
110
if (version >> 8 != 0 || release >> 8 != 0 || modification >> 8 != 0 || fix_level >> 8 != 0) {
111
trcVerbose("8 bit numbers expected");
114
} while (odm.retrieve_obj());
116
if (version != major_aix_version || release != minor_aix_version) {
117
trcVerbose("version determined by odm does not match uname");
120
*p_ver = version << 24 | release << 16 | modification << 8 | fix_level;