duke@435: /* duke@435: * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: # include "incls/_precompiled.incl" duke@435: # include "incls/_hpi.cpp.incl" duke@435: duke@435: extern "C" { duke@435: static void unimplemented_panic(const char *fmt, ...) { coleenp@548: // mitigate testing damage from bug 6626677 coleenp@548: warning("hpi::unimplemented_panic called"); duke@435: } duke@435: duke@435: static void unimplemented_monitorRegister(sys_mon_t *mid, char *info_str) { duke@435: Unimplemented(); duke@435: } duke@435: } duke@435: duke@435: static vm_calls_t callbacks = { duke@435: jio_fprintf, duke@435: unimplemented_panic, duke@435: unimplemented_monitorRegister, duke@435: duke@435: NULL, // unused duke@435: NULL, // unused duke@435: NULL // unused duke@435: }; duke@435: duke@435: GetInterfaceFunc hpi::_get_interface = NULL; duke@435: HPI_FileInterface* hpi::_file = NULL; duke@435: HPI_SocketInterface* hpi::_socket = NULL; duke@435: HPI_LibraryInterface* hpi::_library = NULL; duke@435: HPI_SystemInterface* hpi::_system = NULL; duke@435: duke@435: jint hpi::initialize() duke@435: { duke@435: initialize_get_interface(&callbacks); duke@435: if (_get_interface == NULL) duke@435: return JNI_ERR; duke@435: duke@435: jint result; duke@435: duke@435: result = (*_get_interface)((void **)&_file, "File", 1); duke@435: if (result != 0) { duke@435: if (TraceHPI) tty->print_cr("Can't find HPI_FileInterface"); duke@435: return JNI_ERR; duke@435: } duke@435: duke@435: duke@435: result = (*_get_interface)((void **)&_library, "Library", 1); duke@435: if (result != 0) { duke@435: if (TraceHPI) tty->print_cr("Can't find HPI_LibraryInterface"); duke@435: return JNI_ERR; duke@435: } duke@435: duke@435: result = (*_get_interface)((void **)&_system, "System", 1); duke@435: if (result != 0) { duke@435: if (TraceHPI) tty->print_cr("Can't find HPI_SystemInterface"); duke@435: return JNI_ERR; duke@435: } duke@435: duke@435: return JNI_OK; duke@435: } duke@435: duke@435: jint hpi::initialize_socket_library() duke@435: { duke@435: if (_get_interface == NULL) { duke@435: if (TraceHPI) { duke@435: tty->print_cr("Fatal HPI error: reached initialize_socket_library with NULL _get_interface"); duke@435: } duke@435: return JNI_ERR; duke@435: } duke@435: duke@435: jint result; duke@435: result = (*_get_interface)((void **)&_socket, "Socket", 1); duke@435: if (result != 0) { duke@435: if (TraceHPI) tty->print_cr("Can't find HPI_SocketInterface"); duke@435: return JNI_ERR; duke@435: } duke@435: duke@435: return JNI_OK; duke@435: }