mirror of https://github.com/PCSX2/pcsx2.git
Add network capability for Linux (#2586)
This commit is contained in:
parent
694546e870
commit
da1eb056a3
|
@ -0,0 +1,74 @@
|
|||
# - Try to find libpcap include dirs and libraries
|
||||
#
|
||||
# Usage of this module as follows:
|
||||
#
|
||||
# find_package(PCAP)
|
||||
#
|
||||
# Variables used by this module, they can change the default behaviour and need
|
||||
# to be set before calling find_package:
|
||||
#
|
||||
# PCAP_ROOT_DIR Set this variable to the root installation of
|
||||
# libpcap if the module has problems finding the
|
||||
# proper installation path.
|
||||
#
|
||||
# Variables defined by this module:
|
||||
#
|
||||
# PCAP_FOUND System has libpcap, include and library dirs found
|
||||
# PCAP_INCLUDE_DIR The libpcap include directories.
|
||||
# PCAP_LIBRARY The libpcap library (possibly includes a thread
|
||||
# library e.g. required by pf_ring's libpcap)
|
||||
# HAVE_PF_RING If a found version of libpcap supports PF_RING
|
||||
|
||||
find_path(PCAP_ROOT_DIR
|
||||
NAMES include/pcap.h
|
||||
)
|
||||
|
||||
find_path(PCAP_INCLUDE_DIR
|
||||
NAMES pcap.h
|
||||
HINTS ${PCAP_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
find_library(PCAP_LIBRARY
|
||||
NAMES pcap
|
||||
HINTS ${PCAP_ROOT_DIR}/lib
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PCAP DEFAULT_MSG
|
||||
PCAP_LIBRARY
|
||||
PCAP_INCLUDE_DIR
|
||||
)
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
|
||||
check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
# check if linking against libpcap also needs to link against a thread library
|
||||
if (NOT PCAP_LINKS_SOLO)
|
||||
find_package(Threads)
|
||||
if (THREADS_FOUND)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
||||
check_c_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
endif ()
|
||||
if (THREADS_FOUND AND PCAP_NEEDS_THREADS)
|
||||
set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
||||
list(REMOVE_DUPLICATES _tmp)
|
||||
set(PCAP_LIBRARY ${_tmp}
|
||||
CACHE STRING "Libraries needed to link against libpcap" FORCE)
|
||||
else ()
|
||||
message(FATAL_ERROR "Couldn't determine how to link against libpcap")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include(CheckFunctionExists)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
|
||||
check_function_exists(pcap_get_pfring_id HAVE_PF_RING)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
mark_as_advanced(
|
||||
PCAP_ROOT_DIR
|
||||
PCAP_INCLUDE_DIR
|
||||
PCAP_LIBRARY
|
||||
)
|
|
@ -4,6 +4,8 @@
|
|||
## Use cmake package to find module
|
||||
if (Linux)
|
||||
find_package(ALSA)
|
||||
find_package(PCAP)
|
||||
find_package(LibXml2)
|
||||
endif()
|
||||
find_package(Freetype) # GSdx OSD
|
||||
find_package(Gettext) # translation tool
|
||||
|
@ -173,6 +175,14 @@ if(wxWidgets_FOUND)
|
|||
include(${wxWidgets_USE_FILE})
|
||||
endif()
|
||||
|
||||
if(PCAP_FOUND)
|
||||
include_directories(${PCAP_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(LIBXML2_FOUND)
|
||||
include_directories(${LIBXML2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(ZLIB_FOUND)
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
|
|
@ -116,6 +116,15 @@ if(GTKn_FOUND)
|
|||
set(dev9null TRUE)
|
||||
endif()
|
||||
#---------------------------------------
|
||||
# dev9ghzdrk
|
||||
#---------------------------------------
|
||||
if(GTKn_FOUND AND PCAP_FOUND AND LIBXML2_FOUND)
|
||||
set(dev9ghzdrk TRUE)
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
${CMAKE_MODULE_PATH}/macros)
|
||||
include(GlibCompileResourcesSupport)
|
||||
endif()
|
||||
#---------------------------------------
|
||||
|
||||
#---------------------------------------
|
||||
# FWnull
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# This file is used to be invoked at build time. It generates the needed
|
||||
# resource XML file.
|
||||
|
||||
# Input variables that need to provided when invoking this script:
|
||||
# GXML_OUTPUT The output file path where to save the XML file.
|
||||
# GXML_COMPRESS_ALL Sets all COMPRESS flags in all resources in resource
|
||||
# list.
|
||||
# GXML_NO_COMPRESS_ALL Removes all COMPRESS flags in all resources in
|
||||
# resource list.
|
||||
# GXML_STRIPBLANKS_ALL Sets all STRIPBLANKS flags in all resources in
|
||||
# resource list.
|
||||
# GXML_NO_STRIPBLANKS_ALL Removes all STRIPBLANKS flags in all resources in
|
||||
# resource list.
|
||||
# GXML_TOPIXDATA_ALL Sets all TOPIXDATA flags i nall resources in resource
|
||||
# list.
|
||||
# GXML_NO_TOPIXDATA_ALL Removes all TOPIXDATA flags in all resources in
|
||||
# resource list.
|
||||
# GXML_PREFIX Overrides the resource prefix that is prepended to
|
||||
# each relative name in registered resources.
|
||||
# GXML_RESOURCES The list of resource files. Whether absolute or
|
||||
# relative path is equal.
|
||||
|
||||
# Include the GENERATE_GXML() function.
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/GenerateGXML.cmake)
|
||||
|
||||
# Set flags to actual invocation flags.
|
||||
if(GXML_COMPRESS_ALL)
|
||||
set(GXML_COMPRESS_ALL COMPRESS_ALL)
|
||||
endif()
|
||||
if(GXML_NO_COMPRESS_ALL)
|
||||
set(GXML_NO_COMPRESS_ALL NO_COMPRESS_ALL)
|
||||
endif()
|
||||
if(GXML_STRIPBLANKS_ALL)
|
||||
set(GXML_STRIPBLANKS_ALL STRIPBLANKS_ALL)
|
||||
endif()
|
||||
if(GXML_NO_STRIPBLANKS_ALL)
|
||||
set(GXML_NO_STRIPBLANKS_ALL NO_STRIPBLANKS_ALL)
|
||||
endif()
|
||||
if(GXML_TOPIXDATA_ALL)
|
||||
set(GXML_TOPIXDATA_ALL TOPIXDATA_ALL)
|
||||
endif()
|
||||
if(GXML_NO_TOPIXDATA_ALL)
|
||||
set(GXML_NO_TOPIXDATA_ALL NO_TOPIXDATA_ALL)
|
||||
endif()
|
||||
|
||||
# Replace " " with ";" to import the list over the command line. Otherwise
|
||||
# CMake would interprete the passed resources as a whole string.
|
||||
string(REPLACE " " ";" GXML_RESOURCES ${GXML_RESOURCES})
|
||||
|
||||
# Invoke the gresource XML generation function.
|
||||
generate_gxml(${GXML_OUTPUT}
|
||||
${GXML_COMPRESS_ALL} ${GXML_NO_COMPRESS_ALL}
|
||||
${GXML_STRIPBLANKS_ALL} ${GXML_NO_STRIPBLANKS_ALL}
|
||||
${GXML_TOPIXDATA_ALL} ${GXML_NO_TOPIXDATA_ALL}
|
||||
PREFIX ${GXML_PREFIX}
|
||||
RESOURCES ${GXML_RESOURCES})
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
include(CMakeParseArguments)
|
||||
|
||||
# Path to this file.
|
||||
set(GCR_CMAKE_MACRO_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Compiles a gresource resource file from given resource files. Automatically
|
||||
# creates the XML controlling file.
|
||||
# The type of resource to generate (header, c-file or bundle) is automatically
|
||||
# determined from TARGET file ending, if no TYPE is explicitly specified.
|
||||
# The output file is stored in the provided variable "output".
|
||||
# "xml_out" contains the variable where to output the XML path. Can be used to
|
||||
# create custom targets or doing postprocessing.
|
||||
# If you want to use preprocessing, you need to manually check the existence
|
||||
# of the tools you use. This function doesn't check this for you, it just
|
||||
# generates the XML file. glib-compile-resources will then throw a
|
||||
# warning/error.
|
||||
function(COMPILE_GRESOURCES output xml_out)
|
||||
# Available options:
|
||||
# COMPRESS_ALL, NO_COMPRESS_ALL Overrides the COMPRESS flag in all
|
||||
# registered resources.
|
||||
# STRIPBLANKS_ALL, NO_STRIPBLANKS_ALL Overrides the STRIPBLANKS flag in all
|
||||
# registered resources.
|
||||
# TOPIXDATA_ALL, NO_TOPIXDATA_ALL Overrides the TOPIXDATA flag in all
|
||||
# registered resources.
|
||||
set(CG_OPTIONS COMPRESS_ALL NO_COMPRESS_ALL
|
||||
STRIPBLANKS_ALL NO_STRIPBLANKS_ALL
|
||||
TOPIXDATA_ALL NO_TOPIXDATA_ALL)
|
||||
|
||||
# Available one value options:
|
||||
# TYPE Type of resource to create. Valid options are:
|
||||
# EMBED_C: A C-file that can be compiled with your project.
|
||||
# EMBED_H: A header that can be included into your project.
|
||||
# BUNDLE: Generates a resource bundle file that can be loaded
|
||||
# at runtime.
|
||||
# AUTO: Determine from target file ending. Need to specify
|
||||
# target argument.
|
||||
# PREFIX Overrides the resource prefix that is prepended to each
|
||||
# relative file name in registered resources.
|
||||
# C_PREFIX Specifies the prefix used for the C identifiers in the code generated
|
||||
# when EMBED_C or EMBED_H are specified for TYPE.
|
||||
# SOURCE_DIR Overrides the resources base directory to search for resources.
|
||||
# Normally this is set to the source directory with that CMake
|
||||
# was invoked (CMAKE_CURRENT_SOURCE_DIR).
|
||||
# TARGET Overrides the name of the output file/-s. Normally the output
|
||||
# names from the glib-compile-resources tool are taken.
|
||||
set(CG_ONEVALUEARGS TYPE PREFIX C_PREFIX SOURCE_DIR TARGET)
|
||||
|
||||
# Available multi-value options:
|
||||
# RESOURCES The list of resource files. Whether absolute or relative path is
|
||||
# equal, absolute paths are stripped down to relative ones. If the
|
||||
# absolute path is not inside the given base directory SOURCE_DIR
|
||||
# or CMAKE_CURRENT_SOURCE_DIR (if SOURCE_DIR is not overriden),
|
||||
# this function aborts.
|
||||
# OPTIONS Extra command line options passed to glib-compile-resources.
|
||||
set(CG_MULTIVALUEARGS RESOURCES OPTIONS)
|
||||
|
||||
# Parse the arguments.
|
||||
cmake_parse_arguments(CG_ARG
|
||||
"${CG_OPTIONS}"
|
||||
"${CG_ONEVALUEARGS}"
|
||||
"${CG_MULTIVALUEARGS}"
|
||||
"${ARGN}")
|
||||
|
||||
# Variable to store the double-quote (") string. Since escaping
|
||||
# double-quotes in strings is not possible we need a helper variable that
|
||||
# does this job for us.
|
||||
set(Q \")
|
||||
|
||||
# Check invocation validity with the <prefix>_UNPARSED_ARGUMENTS variable.
|
||||
# If other not recognized parameters were passed, throw error.
|
||||
if (CG_ARG_UNPARSED_ARGUMENTS)
|
||||
set(CG_WARNMSG "Invocation of COMPILE_GRESOURCES with unrecognized")
|
||||
set(CG_WARNMSG "${CG_WARNMSG} parameters. Parameters are:")
|
||||
set(CG_WARNMSG "${CG_WARNMSG} ${CG_ARG_UNPARSED_ARGUMENTS}.")
|
||||
message(WARNING ${CG_WARNMSG})
|
||||
endif()
|
||||
|
||||
# Check invocation validity depending on generation mode (EMBED_C, EMBED_H
|
||||
# or BUNDLE).
|
||||
if ("${CG_ARG_TYPE}" STREQUAL "EMBED_C")
|
||||
# EMBED_C mode, output compilable C-file.
|
||||
list(APPEND CG_GENERATE_COMMAND_LINE --generate-source)
|
||||
if (NOT "${CG_ARG_C_PREFIX}" STREQUAL "")
|
||||
list(APPEND CG_GENERATE_COMMAND_LINE --c-name "${CG_ARG_C_PREFIX}")
|
||||
endif()
|
||||
set(CG_TARGET_FILE_ENDING "c")
|
||||
elseif ("${CG_ARG_TYPE}" STREQUAL "EMBED_H")
|
||||
# EMBED_H mode, output includable header file.
|
||||
list(APPEND CG_GENERATE_COMMAND_LINE --generate-header)
|
||||
if (NOT "${CG_ARG_C_PREFIX}" STREQUAL "")
|
||||
list(APPEND CG_GENERATE_COMMAND_LINE --c-name "${CG_ARG_C_PREFIX}")
|
||||
endif()
|
||||
set(CG_TARGET_FILE_ENDING "h")
|
||||
elseif ("${CG_ARG_TYPE}" STREQUAL "BUNDLE")
|
||||
# BUNDLE mode, output resource bundle. Don't do anything since
|
||||
# glib-compile-resources outputs a bundle when not specifying
|
||||
# something else.
|
||||
set(CG_TARGET_FILE_ENDING "gresource")
|
||||
if (NOT "${CG_ARG_C_PREFIX}" STREQUAL "")
|
||||
message(WARNING "Superfluously provided C_PREFIX=${CG_ARG_C_PREFIX} for BUNDLE.")
|
||||
endif()
|
||||
else()
|
||||
# Everything else is AUTO mode, determine from target file ending.
|
||||
if (CG_ARG_TARGET)
|
||||
list(APPEND CG_GENERATE_COMMAND_LINE --generate)
|
||||
else()
|
||||
set(CG_ERRMSG "AUTO mode given, but no target specified. Can't")
|
||||
set(CG_ERRMSG "${CG_ERRMSG} determine output type. In function")
|
||||
set(CG_ERRMSG "${CG_ERRMSG} COMPILE_GRESOURCES.")
|
||||
message(FATAL_ERROR ${CG_ERRMSG})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check flag validity.
|
||||
if (CG_ARG_COMPRESS_ALL AND CG_ARG_NO_COMPRESS_ALL)
|
||||
set(CG_ERRMSG "COMPRESS_ALL and NO_COMPRESS_ALL simultaneously set. In")
|
||||
set(CG_ERRMSG "${CG_ERRMSG} function COMPILE_GRESOURCES.")
|
||||
message(FATAL_ERROR ${CG_ERRMSG})
|
||||
endif()
|
||||
if (CG_ARG_STRIPBLANKS_ALL AND CG_ARG_NO_STRIPBLANKS_ALL)
|
||||
set(CG_ERRMSG "STRIPBLANKS_ALL and NO_STRIPBLANKS_ALL simultaneously")
|
||||
set(CG_ERRMSG "${CG_ERRMSG} set. In function COMPILE_GRESOURCES.")
|
||||
message(FATAL_ERROR ${CG_ERRMSG})
|
||||
endif()
|
||||
if (CG_ARG_TOPIXDATA_ALL AND CG_ARG_NO_TOPIXDATA_ALL)
|
||||
set(CG_ERRMSG "TOPIXDATA_ALL and NO_TOPIXDATA_ALL simultaneously set.")
|
||||
set(CG_ERRMSG "${CG_ERRMSG} In function COMPILE_GRESOURCES.")
|
||||
message(FATAL_ERROR ${CG_ERRMSG})
|
||||
endif()
|
||||
|
||||
# Check if there are any resources.
|
||||
if (NOT CG_ARG_RESOURCES)
|
||||
set(CG_ERRMSG "No resource files to process. In function")
|
||||
set(CG_ERRMSG "${CG_ERRMSG} COMPILE_GRESOURCES.")
|
||||
message(FATAL_ERROR ${CG_ERRMSG})
|
||||
endif()
|
||||
|
||||
# Extract all dependencies for targets from resource list.
|
||||
foreach(res ${CG_ARG_RESOURCES})
|
||||
if (NOT(("${res}" STREQUAL "COMPRESS") OR
|
||||
("${res}" STREQUAL "STRIPBLANKS") OR
|
||||
("${res}" STREQUAL "TOPIXDATA")))
|
||||
|
||||
list(APPEND CG_RESOURCES_DEPENDENCIES "${res}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Construct .gresource.xml path.
|
||||
set(CG_XML_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/.gresource.xml")
|
||||
|
||||
# Generate gresources XML target.
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_OUTPUT=${Q}${CG_XML_FILE_PATH}${Q}")
|
||||
if(CG_ARG_COMPRESS_ALL)
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_COMPRESS_ALL=True")
|
||||
endif()
|
||||
if(CG_ARG_NO_COMPRESS_ALL)
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_COMPRESS_ALL=True")
|
||||
endif()
|
||||
if(CG_ARG_STRPIBLANKS_ALL)
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_STRIPBLANKS_ALL=True")
|
||||
endif()
|
||||
if(CG_ARG_NO_STRIPBLANKS_ALL)
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_STRIPBLANKS_ALL=True")
|
||||
endif()
|
||||
if(CG_ARG_TOPIXDATA_ALL)
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_TOPIXDATA_ALL=True")
|
||||
endif()
|
||||
if(CG_ARG_NO_TOPIXDATA_ALL)
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_NO_TOPIXDATA_ALL=True")
|
||||
endif()
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "GXML_PREFIX=${Q}${CG_ARG_PREFIX}${Q}")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-D")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS
|
||||
"GXML_RESOURCES=${Q}${CG_ARG_RESOURCES}${Q}")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS "-P")
|
||||
list(APPEND CG_CMAKE_SCRIPT_ARGS
|
||||
"${Q}${GCR_CMAKE_MACRO_DIR}/BuildTargetScript.cmake${Q}")
|
||||
|
||||
get_filename_component(CG_XML_FILE_PATH_ONLY_NAME
|
||||
"${CG_XML_FILE_PATH}" NAME)
|
||||
set(CG_XML_CUSTOM_COMMAND_COMMENT
|
||||
"Creating gresources XML file (${CG_XML_FILE_PATH_ONLY_NAME})")
|
||||
add_custom_command(OUTPUT ${CG_XML_FILE_PATH}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS ${CG_CMAKE_SCRIPT_ARGS}
|
||||
DEPENDS ${CG_RESOURCES_DEPENDENCIES}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT ${CG_XML_CUSTOM_COMMAND_COMMENT})
|
||||
|
||||
# Create target manually if not set (to make sure glib-compile-resources
|
||||
# doesn't change behaviour with it's naming standards).
|
||||
if (NOT CG_ARG_TARGET)
|
||||
set(CG_ARG_TARGET "${CMAKE_CURRENT_BINARY_DIR}/resources")
|
||||
set(CG_ARG_TARGET "${CG_ARG_TARGET}.${CG_TARGET_FILE_ENDING}")
|
||||
endif()
|
||||
|
||||
# Create source directory automatically if not set.
|
||||
if (NOT CG_ARG_SOURCE_DIR)
|
||||
set(CG_ARG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# Add compilation target for resources.
|
||||
add_custom_command(OUTPUT ${CG_ARG_TARGET}
|
||||
COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
|
||||
ARGS
|
||||
${OPTIONS}
|
||||
--target ${CG_ARG_TARGET}
|
||||
--sourcedir ${CG_ARG_SOURCE_DIR}
|
||||
${CG_GENERATE_COMMAND_LINE}
|
||||
${CG_XML_FILE_PATH}
|
||||
VERBATIM
|
||||
MAIN_DEPENDENCY ${CG_XML_FILE_PATH}
|
||||
DEPENDS ${CG_RESOURCES_DEPENDENCIES}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BUILD_DIR})
|
||||
|
||||
# Set output and XML_OUT to parent scope.
|
||||
set(${xml_out} ${CG_XML_FILE_PATH} PARENT_SCOPE)
|
||||
set(${output} ${CG_ARG_TARGET} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
|
@ -0,0 +1,124 @@
|
|||
include(CMakeParseArguments)
|
||||
|
||||
# Generates the resource XML controlling file from resource list (and saves it
|
||||
# to xml_path). It's not recommended to use this function directly, since it
|
||||
# doesn't handle invalid arguments. It is used by the function
|
||||
# COMPILE_GRESOURCES() to create a custom command, so that this function is
|
||||
# invoked at build-time in script mode from CMake.
|
||||
function(GENERATE_GXML xml_path)
|
||||
# Available options:
|
||||
# COMPRESS_ALL, NO_COMPRESS_ALL Overrides the COMPRESS flag in all
|
||||
# registered resources.
|
||||
# STRIPBLANKS_ALL, NO_STRIPBLANKS_ALL Overrides the STRIPBLANKS flag in all
|
||||
# registered resources.
|
||||
# TOPIXDATA_ALL, NO_TOPIXDATA_ALL Overrides the TOPIXDATA flag in all
|
||||
# registered resources.
|
||||
set(GXML_OPTIONS COMPRESS_ALL NO_COMPRESS_ALL
|
||||
STRIPBLANKS_ALL NO_STRIPBLANKS_ALL
|
||||
TOPIXDATA_ALL NO_TOPIXDATA_ALL)
|
||||
|
||||
# Available one value options:
|
||||
# PREFIX Overrides the resource prefix that is prepended to each
|
||||
# relative file name in registered resources.
|
||||
set(GXML_ONEVALUEARGS PREFIX)
|
||||
|
||||
# Available multi-value options:
|
||||
# RESOURCES The list of resource files. Whether absolute or relative path is
|
||||
# equal, absolute paths are stripped down to relative ones. If the
|
||||
# absolute path is not inside the given base directory SOURCE_DIR
|
||||
# or CMAKE_CURRENT_SOURCE_DIR (if SOURCE_DIR is not overriden),
|
||||
# this function aborts.
|
||||
set(GXML_MULTIVALUEARGS RESOURCES)
|
||||
|
||||
# Parse the arguments.
|
||||
cmake_parse_arguments(GXML_ARG
|
||||
"${GXML_OPTIONS}"
|
||||
"${GXML_ONEVALUEARGS}"
|
||||
"${GXML_MULTIVALUEARGS}"
|
||||
"${ARGN}")
|
||||
|
||||
# Variable to store the double-quote (") string. Since escaping
|
||||
# double-quotes in strings is not possible we need a helper variable that
|
||||
# does this job for us.
|
||||
set(Q \")
|
||||
|
||||
# Process resources and generate XML file.
|
||||
# Begin with the XML header and header nodes.
|
||||
set(GXML_XML_FILE "<?xml version=${Q}1.0${Q} encoding=${Q}UTF-8${Q}?>")
|
||||
set(GXML_XML_FILE "${GXML_XML_FILE}<gresources><gresource prefix=${Q}")
|
||||
|
||||
# Set the prefix for the resources. Depending on the user-override we choose
|
||||
# the standard prefix "/" or the override.
|
||||
if (GXML_ARG_PREFIX)
|
||||
set(GXML_XML_FILE "${GXML_XML_FILE}${GXML_ARG_PREFIX}")
|
||||
else()
|
||||
set(GXML_XML_FILE "${GXML_XML_FILE}/")
|
||||
endif()
|
||||
|
||||
set(GXML_XML_FILE "${GXML_XML_FILE}${Q}>")
|
||||
|
||||
# Process each resource.
|
||||
foreach(res ${GXML_ARG_RESOURCES})
|
||||
if ("${res}" STREQUAL "COMPRESS")
|
||||
set(GXML_COMPRESSION_FLAG ON)
|
||||
elseif ("${res}" STREQUAL "STRIPBLANKS")
|
||||
set(GXML_STRIPBLANKS_FLAG ON)
|
||||
elseif ("${res}" STREQUAL "TOPIXDATA")
|
||||
set(GXML_TOPIXDATA_FLAG ON)
|
||||
else()
|
||||
# The file name.
|
||||
set(GXML_RESOURCE_PATH "${res}")
|
||||
|
||||
# Append to real resource file dependency list.
|
||||
list(APPEND GXML_RESOURCES_DEPENDENCIES ${GXML_RESOURCE_PATH})
|
||||
|
||||
# Assemble <file> node.
|
||||
set(GXML_RES_LINE "<file")
|
||||
if ((GXML_ARG_COMPRESS_ALL OR GXML_COMPRESSION_FLAG) AND NOT
|
||||
GXML_ARG_NO_COMPRESS_ALL)
|
||||
set(GXML_RES_LINE "${GXML_RES_LINE} compressed=${Q}true${Q}")
|
||||
endif()
|
||||
|
||||
# Check preprocess flag validity.
|
||||
if ((GXML_ARG_STRIPBLANKS_ALL OR GXML_STRIPBLANKS_FLAG) AND
|
||||
(GXML_ARG_TOPIXDATA_ALL OR GXML_TOPIXDATA_FLAG))
|
||||
set(GXML_ERRMSG "Resource preprocessing option conflict. Tried")
|
||||
set(GXML_ERRMSG "${GXML_ERRMSG} to specify both, STRIPBLANKS")
|
||||
set(GXML_ERRMSG "${GXML_ERRMSG} and TOPIXDATA. In resource")
|
||||
set(GXML_ERRMSG "${GXML_ERRMSG} ${GXML_RESOURCE_PATH} in")
|
||||
set(GXML_ERRMSG "${GXML_ERRMSG} function COMPILE_GRESOURCES.")
|
||||
message(FATAL_ERROR ${GXML_ERRMSG})
|
||||
endif()
|
||||
|
||||
if ((GXML_ARG_STRIPBLANKS_ALL OR GXML_STRIPBLANKS_FLAG) AND NOT
|
||||
GXML_ARG_NO_STRIPBLANKS_ALL)
|
||||
set(GXML_RES_LINE "${GXML_RES_LINE} preprocess=")
|
||||
set(GXML_RES_LINE "${GXML_RES_LINE}${Q}xml-stripblanks${Q}")
|
||||
elseif((GXML_ARG_TOPIXDATA_ALL OR GXML_TOPIXDATA_FLAG) AND NOT
|
||||
GXML_ARG_NO_TOPIXDATA_ALL)
|
||||
set(GXML_RES_LINE "${GXML_RES_LINE} preprocess=")
|
||||
set(GXML_RES_LINE "${GXML_RES_LINE}${Q}to-pixdata${Q}")
|
||||
endif()
|
||||
|
||||
set(GXML_RES_LINE "${GXML_RES_LINE}>${GXML_RESOURCE_PATH}</file>")
|
||||
|
||||
# Append to file string.
|
||||
set(GXML_XML_FILE "${GXML_XML_FILE}${GXML_RES_LINE}")
|
||||
|
||||
# Unset variables.
|
||||
unset(GXML_COMPRESSION_FLAG)
|
||||
unset(GXML_STRIPBLANKS_FLAG)
|
||||
unset(GXML_TOPIXDATA_FLAG)
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
# Append closing nodes.
|
||||
set(GXML_XML_FILE "${GXML_XML_FILE}</gresource></gresources>")
|
||||
|
||||
# Use "file" function to generate XML controlling file.
|
||||
get_filename_component(xml_path_only_name "${xml_path}" NAME)
|
||||
file(WRITE ${xml_path} ${GXML_XML_FILE})
|
||||
|
||||
endfunction()
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Path to this file.
|
||||
set(GCR_CMAKE_MACRO_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Finds the glib-compile-resources executable.
|
||||
find_program(GLIB_COMPILE_RESOURCES_EXECUTABLE glib-compile-resources)
|
||||
mark_as_advanced(GLIB_COMPILE_RESOURCES_EXECUTABLE)
|
||||
|
||||
# Include the cmake files containing the functions.
|
||||
include(${GCR_CMAKE_MACRO_DIR}/CompileGResources.cmake)
|
||||
include(${GCR_CMAKE_MACRO_DIR}/GenerateGXML.cmake)
|
||||
|
|
@ -705,3 +705,9 @@ if(USE_VTUNE)
|
|||
endif()
|
||||
|
||||
add_pcsx2_executable(${Output} "${pcsx2FinalSources}" "${pcsx2FinalLibs}" "${pcsx2FinalFlags}")
|
||||
|
||||
if(PACKAGE_MODE)
|
||||
install(CODE "execute_process(COMMAND /bin/bash -c \"echo 'Enabling networking capability on Linux...';set -x; [ -f ${BIN_DIR}/${Output} ] && sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ${BIN_DIR}/${Output}; set +x\")")
|
||||
else()
|
||||
install(CODE "execute_process(COMMAND /bin/bash -c \"echo 'Enabling networking capability on Linux...';set -x; [ -f ${CMAKE_SOURCE_DIR}/bin/${Output} ] && sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ${CMAKE_SOURCE_DIR}/bin/${Output}; set +x\")")
|
||||
endif()
|
||||
|
|
|
@ -22,6 +22,10 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/plugins/dev9null" AND dev9null)
|
|||
add_subdirectory(dev9null)
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/plugins/dev9ghzdrk" AND dev9ghzdrk)
|
||||
add_subdirectory(dev9ghzdrk)
|
||||
endif()
|
||||
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/plugins/FWnull" AND FWnull)
|
||||
add_subdirectory(FWnull)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
# Check that people use the good file
|
||||
if(NOT TOP_CMAKE_WAS_SOURCED)
|
||||
message(FATAL_ERROR "
|
||||
You did not 'cmake' the good CMakeLists.txt file. Use the one in the top dir.
|
||||
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
|
||||
endif(NOT TOP_CMAKE_WAS_SOURCED)
|
||||
|
||||
# plugin name
|
||||
set(Output dev9ghzdrk-0.4)
|
||||
|
||||
set(CommonFlags
|
||||
-fvisibility=hidden
|
||||
-Wall
|
||||
-fpermissive
|
||||
-I${LIBXML2_INCLUDE_DIR}
|
||||
-I${PCAP_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(OptimizationFlags
|
||||
-O2
|
||||
-DNDEBUG
|
||||
)
|
||||
|
||||
# Debug - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
# add defines
|
||||
set(dev9ghzdrkFinalFlags
|
||||
${CommonFlags} -g
|
||||
)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
# Devel - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Devel)
|
||||
# add defines
|
||||
set(dev9ghzdrkFinalFlags
|
||||
${CommonFlags} ${OptimizationFlags}
|
||||
)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Devel)
|
||||
|
||||
# Release - Build
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
# add defines
|
||||
set(dev9ghzdrkFinalFlags
|
||||
${CommonFlags} ${OptimizationFlags}
|
||||
)
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
|
||||
# dev9ghzdrk sources
|
||||
set(dev9ghzdrkSources
|
||||
smap.cpp
|
||||
DEV9.cpp
|
||||
flash.cpp
|
||||
pcap_io.cpp
|
||||
)
|
||||
|
||||
# dev9ghzdrk headers
|
||||
set(dev9ghzdrkHeaders
|
||||
)
|
||||
|
||||
compile_gresources( dev9ghzdrkUI_C
|
||||
dev9ghzdrkUI_XML
|
||||
TYPE EMBED_C
|
||||
RESOURCES "Linux/dev9ghzdrk.ui"
|
||||
PREFIX "/net/pcsx2/dev9ghzdrk"
|
||||
COMPRESS_ALL
|
||||
STRIPBLANKS_ALL
|
||||
)
|
||||
|
||||
compile_gresources( dev9ghzdrkUI_H
|
||||
dev9ghzdrkUI_XML
|
||||
TYPE EMBED_H
|
||||
RESOURCES "Linux/dev9ghzdrk.ui"
|
||||
PREFIX "/net/pcsx2/dev9ghzdrk"
|
||||
COMPRESS_ALL
|
||||
STRIPBLANKS_ALL
|
||||
)
|
||||
|
||||
# dev9ghzdrk Linux sources
|
||||
set(dev9ghzdrkLinuxSources
|
||||
Linux/Config.cpp
|
||||
Linux/Linux.cpp
|
||||
Linux/net.cpp
|
||||
${dev9ghzdrkUI_C}
|
||||
)
|
||||
|
||||
# dev9ghzdrk Linux headers
|
||||
set(dev9ghzdrkLinuxHeaders
|
||||
${dev9ghzdrkUI_H}
|
||||
)
|
||||
|
||||
# dev9ghzdrk Windows sources
|
||||
set(dev9ghzdrkWindowsSources
|
||||
Win32/DEV9ghzdrk.def
|
||||
Win32/Config.cpp
|
||||
Win32/Win32.cpp
|
||||
Win32/net.cpp
|
||||
Win32/tap-win32.cpp
|
||||
)
|
||||
|
||||
# dev9ghzdrk Windows headers
|
||||
set(dev9ghzdrkWindowsHeaders
|
||||
)
|
||||
|
||||
set(dev9ghzdrkFinalSources
|
||||
${dev9ghzdrkSources}
|
||||
${dev9ghzdrkHeaders}
|
||||
${dev9ghzdrkLinuxSources}
|
||||
${dev9ghzdrkLinuxHeaders}
|
||||
)
|
||||
|
||||
set(dev9ghzdrkFinalLibs
|
||||
${GTK2_LIBRARIES} ${PCAP_LIBRARY} ${LIBXML2_LIBRARIES}
|
||||
)
|
||||
|
||||
add_pcsx2_plugin(${Output} "${dev9ghzdrkFinalSources}" "${dev9ghzdrkFinalLibs}" "${dev9ghzdrkFinalFlags}")
|
||||
|
||||
#if(PACKAGE_MODE)
|
||||
# install(FILES Linux/dev9ghzdrk.ui DESTINATION bin )
|
||||
#else()
|
||||
# install(FILES Linux/dev9ghzdrk.ui DESTINATION ${CMAKE_SOURCE_DIR}/bin )
|
||||
#endif()
|
|
@ -17,13 +17,21 @@
|
|||
#define WINVER 0x0600
|
||||
#define _WIN32_WINNT 0x0600
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <Winioctl.h>
|
||||
#include <windows.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <err.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <Winioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#define EXTERN
|
||||
#include "DEV9.h"
|
||||
|
@ -40,6 +48,26 @@ HINSTANCE hInst=NULL;
|
|||
|
||||
//#define HDD_48BIT
|
||||
|
||||
#if defined(__i386__) && !defined(_WIN32)
|
||||
|
||||
static __inline__ unsigned long long GetTickCount(void)
|
||||
{
|
||||
unsigned long long int x;
|
||||
__asm__ volatile ("rdtsc" : "=A" (x));
|
||||
return x;
|
||||
}
|
||||
|
||||
#elif defined(__x86_64__) && !defined(_WIN32)
|
||||
|
||||
static __inline__ unsigned long long GetTickCount(void)
|
||||
{
|
||||
unsigned hi, lo;
|
||||
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
u8 eeprom[] = {
|
||||
//0x6D, 0x76, 0x63, 0x61, 0x31, 0x30, 0x08, 0x01,
|
||||
0x76, 0x6D, 0x61, 0x63, 0x30, 0x31, 0x07, 0x02,
|
||||
|
@ -59,24 +87,32 @@ const unsigned char revision = 0;
|
|||
const unsigned char build = 4; // increase that with each version
|
||||
|
||||
|
||||
static char *libraryName = "GiGaHeRz's DEV9 Driver"
|
||||
static const char *libraryName = "GiGaHeRz's DEV9 Driver"
|
||||
#ifdef _DEBUG
|
||||
"(debug)"
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE hEeprom;
|
||||
HANDLE mapping;
|
||||
#else
|
||||
int hEeprom;
|
||||
int mapping;
|
||||
#endif
|
||||
|
||||
u32 CALLBACK PS2EgetLibType() {
|
||||
EXPORT_C_(u32)
|
||||
PS2EgetLibType() {
|
||||
return PS2E_LT_DEV9;
|
||||
}
|
||||
|
||||
const char* CALLBACK PS2EgetLibName() {
|
||||
EXPORT_C_(const char*)
|
||||
PS2EgetLibName() {
|
||||
return libraryName;
|
||||
}
|
||||
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||
EXPORT_C_(u32)
|
||||
PS2EgetLibVersion2(u32 type) {
|
||||
return (version<<16) | (revision<<8) | build;
|
||||
}
|
||||
|
||||
|
@ -121,7 +157,8 @@ void LogInit()
|
|||
DEV9Log.Open(LogFile);
|
||||
}
|
||||
|
||||
s32 CALLBACK DEV9init()
|
||||
EXPORT_C_(s32)
|
||||
DEV9init()
|
||||
{
|
||||
|
||||
#ifdef DEV9_LOG_ENABLE
|
||||
|
@ -135,6 +172,7 @@ s32 CALLBACK DEV9init()
|
|||
|
||||
FLASHinit();
|
||||
|
||||
#ifdef _WIN32
|
||||
hEeprom = CreateFile(
|
||||
"eeprom.dat",
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
|
@ -160,6 +198,7 @@ s32 CALLBACK DEV9init()
|
|||
else
|
||||
{
|
||||
dev9.eeprom = (u16*)MapViewOfFile(mapping,FILE_MAP_WRITE,0,0,0);
|
||||
|
||||
if(dev9.eeprom==NULL)
|
||||
{
|
||||
CloseHandle(mapping);
|
||||
|
@ -168,19 +207,34 @@ s32 CALLBACK DEV9init()
|
|||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
hEeprom = open("eeprom.dat", O_RDWR, 0);
|
||||
|
||||
|
||||
if(-1 == hEeprom)
|
||||
{
|
||||
int rxbi;
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev9.eeprom = (u16*)mmap(NULL, 64, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, hEeprom, 0);
|
||||
|
||||
for(rxbi=0;rxbi<(SMAP_BD_SIZE/8);rxbi++)
|
||||
{
|
||||
smap_bd_t *pbd = (smap_bd_t *)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff];
|
||||
pbd = &pbd[rxbi];
|
||||
if(dev9.eeprom==NULL)
|
||||
{
|
||||
close(hEeprom);
|
||||
dev9.eeprom=(u16*)eeprom;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pbd->ctrl_stat = SMAP_BD_RX_EMPTY;
|
||||
pbd->length = 0;
|
||||
}
|
||||
int rxbi;
|
||||
|
||||
for(rxbi=0;rxbi<(SMAP_BD_SIZE/8);rxbi++)
|
||||
{
|
||||
smap_bd_t *pbd = (smap_bd_t *)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff];
|
||||
pbd = &pbd[rxbi];
|
||||
|
||||
pbd->ctrl_stat = SMAP_BD_RX_EMPTY;
|
||||
pbd->length = 0;
|
||||
}
|
||||
|
||||
DEV9_LOG("DEV9init ok\n");
|
||||
|
@ -188,14 +242,16 @@ s32 CALLBACK DEV9init()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void CALLBACK DEV9shutdown() {
|
||||
EXPORT_C_(void)
|
||||
DEV9shutdown() {
|
||||
DEV9_LOG("DEV9shutdown\n");
|
||||
#ifdef DEV9_LOG_ENABLE
|
||||
DEV9Log.Close();
|
||||
#endif
|
||||
}
|
||||
|
||||
s32 CALLBACK DEV9open(void *pDsp)
|
||||
EXPORT_C_(s32)
|
||||
DEV9open(void *pDsp)
|
||||
{
|
||||
DEV9_LOG("DEV9open\n");
|
||||
LoadConf();
|
||||
|
@ -210,7 +266,8 @@ s32 CALLBACK DEV9open(void *pDsp)
|
|||
return _DEV9open();
|
||||
}
|
||||
|
||||
void CALLBACK DEV9close()
|
||||
EXPORT_C_(void)
|
||||
DEV9close()
|
||||
{
|
||||
DEV9_LOG("DEV9close\n");
|
||||
#ifdef ENABLE_ATA
|
||||
|
@ -219,7 +276,8 @@ void CALLBACK DEV9close()
|
|||
_DEV9close();
|
||||
}
|
||||
|
||||
int CALLBACK _DEV9irqHandler(void)
|
||||
EXPORT_C_(int)
|
||||
_DEV9irqHandler(void)
|
||||
{
|
||||
//dev9Ru16(SPD_R_INTR_STAT)|= dev9.irqcause;
|
||||
DEV9_LOG("_DEV9irqHandler %x, %x\n", dev9.irqcause, dev9Ru16(SPD_R_INTR_MASK));
|
||||
|
@ -228,7 +286,8 @@ int CALLBACK _DEV9irqHandler(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DEV9handler CALLBACK DEV9irqHandler(void) {
|
||||
EXPORT_C_(DEV9handler)
|
||||
DEV9irqHandler(void) {
|
||||
return (DEV9handler)_DEV9irqHandler;
|
||||
}
|
||||
|
||||
|
@ -245,7 +304,8 @@ void _DEV9irq(int cause, int cycles)
|
|||
}
|
||||
|
||||
|
||||
u8 CALLBACK DEV9read8(u32 addr) {
|
||||
EXPORT_C_(u8)
|
||||
DEV9read8(u32 addr) {
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return 0;
|
||||
|
||||
|
@ -312,7 +372,8 @@ u8 CALLBACK DEV9read8(u32 addr) {
|
|||
return hard;
|
||||
}
|
||||
|
||||
u16 CALLBACK DEV9read16(u32 addr)
|
||||
EXPORT_C_(u16)
|
||||
DEV9read16(u32 addr)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return 0;
|
||||
|
@ -377,7 +438,8 @@ u16 CALLBACK DEV9read16(u32 addr)
|
|||
return hard;
|
||||
}
|
||||
|
||||
u32 CALLBACK DEV9read32(u32 addr)
|
||||
EXPORT_C_(u32)
|
||||
DEV9read32(u32 addr)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return 0;
|
||||
|
@ -412,7 +474,8 @@ u32 CALLBACK DEV9read32(u32 addr)
|
|||
// return hard;
|
||||
}
|
||||
|
||||
void CALLBACK DEV9write8(u32 addr, u8 value)
|
||||
EXPORT_C_(void)
|
||||
DEV9write8(u32 addr, u8 value)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
@ -522,7 +585,8 @@ void CALLBACK DEV9write8(u32 addr, u8 value)
|
|||
DEV9_LOG("*Known 8bit write at address %lx value %x\n", addr, value);
|
||||
}
|
||||
|
||||
void CALLBACK DEV9write16(u32 addr, u16 value)
|
||||
EXPORT_C_(void)
|
||||
DEV9write16(u32 addr, u16 value)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
@ -565,7 +629,8 @@ void CALLBACK DEV9write16(u32 addr, u16 value)
|
|||
DEV9_LOG("*Known 16bit write at address %lx value %x\n", addr, value);
|
||||
}
|
||||
|
||||
void CALLBACK DEV9write32(u32 addr, u32 value)
|
||||
EXPORT_C_(void)
|
||||
DEV9write32(u32 addr, u32 value)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
@ -602,7 +667,8 @@ void CALLBACK DEV9write32(u32 addr, u32 value)
|
|||
DEV9_LOG("*Known 32bit write at address %lx value %lx\n", addr, value);
|
||||
}
|
||||
|
||||
void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size)
|
||||
EXPORT_C_(void)
|
||||
DEV9readDMA8Mem(u32 *pMem, int size)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
@ -616,7 +682,8 @@ void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size)
|
|||
#endif
|
||||
}
|
||||
|
||||
void CALLBACK DEV9writeDMA8Mem(u32* pMem, int size)
|
||||
EXPORT_C_(void)
|
||||
DEV9writeDMA8Mem(u32* pMem, int size)
|
||||
{
|
||||
if (!config.ethEnable & !config.hddEnable)
|
||||
return;
|
||||
|
@ -632,29 +699,34 @@ void CALLBACK DEV9writeDMA8Mem(u32* pMem, int size)
|
|||
|
||||
|
||||
//plugin interface
|
||||
void CALLBACK DEV9irqCallback(void (*callback)(int cycles)) {
|
||||
EXPORT_C_(void)
|
||||
DEV9irqCallback(void (*callback)(int cycles)) {
|
||||
DEV9irq = callback;
|
||||
}
|
||||
|
||||
void CALLBACK DEV9async(u32 cycles)
|
||||
EXPORT_C_(void)
|
||||
DEV9async(u32 cycles)
|
||||
{
|
||||
smap_async(cycles);
|
||||
}
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK DEV9test() {
|
||||
EXPORT_C_(s32)
|
||||
DEV9test() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CALLBACK DEV9setSettingsDir(const char* dir)
|
||||
EXPORT_C_(void)
|
||||
DEV9setSettingsDir(const char* dir)
|
||||
{
|
||||
// Grab the ini directory.
|
||||
// TODO: Use
|
||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||
}
|
||||
|
||||
void CALLBACK DEV9setLogDir(const char* dir)
|
||||
EXPORT_C_(void)
|
||||
DEV9setLogDir(const char* dir)
|
||||
{
|
||||
// Get the path to the log directory.
|
||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||
|
|
|
@ -44,12 +44,12 @@
|
|||
|
||||
#endif
|
||||
|
||||
#define DEV9_LOG_ENABLE
|
||||
//#define DEV9_LOG_ENABLE
|
||||
|
||||
#ifdef DEV9_LOG_ENABLE
|
||||
#define DEV9_LOG __Log
|
||||
#else
|
||||
#define DEV9_LOG(...) ()
|
||||
#define DEV9_LOG(...)
|
||||
#endif
|
||||
|
||||
void rx_process(NetPacket* pk);
|
||||
|
@ -638,12 +638,17 @@ static flash_info_t devices[] = {
|
|||
|
||||
#define FLASH_REGSIZE 0x20
|
||||
|
||||
void CALLBACK FLASHinit();
|
||||
u32 CALLBACK FLASHread32(u32 addr, int size);
|
||||
void CALLBACK FLASHwrite32(u32 addr, u32 value, int size);
|
||||
EXPORT_C_(void)
|
||||
FLASHinit();
|
||||
EXPORT_C_(u32)
|
||||
FLASHread32(u32 addr, int size);
|
||||
EXPORT_C_(void)
|
||||
FLASHwrite32(u32 addr, u32 value, int size);
|
||||
void _DEV9irq(int cause, int cycles);
|
||||
|
||||
int emu_printf(const char *fmt, ...);
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(error:4013)
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include <winsock2.h>
|
||||
#include "../DEV9.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
|
||||
void SaveConf() {
|
||||
|
||||
xmlDocPtr doc = NULL; /* document pointer */
|
||||
xmlNodePtr root_node = NULL;
|
||||
char buff[256];
|
||||
|
||||
/*
|
||||
* Creates a new document, a node and set it as a root node
|
||||
*/
|
||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
||||
root_node = xmlNewNode(NULL, BAD_CAST "dev9");
|
||||
xmlDocSetRootElement(doc, root_node);
|
||||
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "Eth",
|
||||
BAD_CAST config.Eth);
|
||||
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "Hdd",
|
||||
BAD_CAST config.Hdd);
|
||||
|
||||
sprintf(buff,"%d",config.HddSize);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "HddSize",
|
||||
BAD_CAST buff);
|
||||
|
||||
sprintf(buff,"%d",config.ethEnable);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "ethEnable",
|
||||
BAD_CAST buff);
|
||||
|
||||
sprintf(buff,"%d",config.hddEnable);
|
||||
xmlNewChild(root_node, NULL, BAD_CAST "hddEnable",
|
||||
BAD_CAST buff);
|
||||
/*
|
||||
* Dumping document to stdio or file
|
||||
*/
|
||||
|
||||
|
||||
const std::string file(s_strIniPath + "dev9ghzdrk.cfg");
|
||||
|
||||
xmlSaveFormatFileEnc(file.c_str(), doc, "UTF-8", 1);
|
||||
// free(configFile);
|
||||
|
||||
/*free the document */
|
||||
xmlFreeDoc(doc);
|
||||
|
||||
/*
|
||||
*Free the global variables that may
|
||||
*have been allocated by the parser.
|
||||
*/
|
||||
xmlCleanupParser();
|
||||
}
|
||||
|
||||
void LoadConf() {
|
||||
|
||||
const std::string file(s_strIniPath + "dev9ghzdrk.cfg");
|
||||
if( -1 == access( file.c_str(), F_OK ) )
|
||||
return;
|
||||
|
||||
memset(&config, 0, sizeof(config));
|
||||
|
||||
// Read the files
|
||||
xmlDoc *doc = NULL;
|
||||
xmlNode *cur_node = NULL;
|
||||
|
||||
doc = xmlReadFile(file.c_str(), NULL, 0);
|
||||
|
||||
if (doc == NULL){
|
||||
SysMessage("Unable to parse configuration file! Suggest deleting it and starting over.");
|
||||
}
|
||||
|
||||
for (cur_node = xmlDocGetRootElement(doc)->children; cur_node; cur_node = cur_node->next) {
|
||||
if (cur_node->type == XML_ELEMENT_NODE) {
|
||||
// printf("node type: Element, name: %s\n", cur_node->name);
|
||||
if(0 == strcmp((const char*)cur_node->name, "Eth")) {
|
||||
strcpy(config.Eth, (const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "Hdd")) {
|
||||
strcpy(config.Hdd, (const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "HddSize")) {
|
||||
config.HddSize = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "ethEnable")) {
|
||||
config.ethEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
if(0 == strcmp((const char*)cur_node->name, "hddEnable")) {
|
||||
config.hddEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// free(configFile);
|
||||
xmlFreeDoc(doc);
|
||||
xmlCleanupParser();
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Config.h"
|
||||
#include "../DEV9.h"
|
||||
#include "pcap.h"
|
||||
#include "pcap_io.h"
|
||||
#include "net.h"
|
||||
|
||||
static GtkBuilder * builder;
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(tmp,fmt,list);
|
||||
va_end(list);
|
||||
|
||||
GtkWidget *dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", tmp);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
gtk_widget_hide(dialog);
|
||||
}
|
||||
|
||||
void OnInitDialog() {
|
||||
char *dev;
|
||||
gint idx = 0;
|
||||
static int initialized = 0;
|
||||
|
||||
LoadConf();
|
||||
|
||||
if( initialized )
|
||||
return;
|
||||
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_BAYTYPE"),"Expansion");
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_BAYTYPE"),"PC Card");
|
||||
for (int i=0; i<pcap_io_get_dev_num(); i++) {
|
||||
dev = pcap_io_get_dev_name(i);
|
||||
gtk_combo_box_text_append_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_ETHDEV"), dev);
|
||||
if (strcmp(dev, config.Eth) == 0) {
|
||||
gtk_combo_box_set_active((GtkComboBox *)gtk_builder_get_object(builder,"IDC_ETHDEV"),idx);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
gtk_entry_set_text ((GtkEntry *)gtk_builder_get_object(builder,"IDC_HDDFILE"), config.Hdd);
|
||||
gtk_toggle_button_set_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_ETHENABLED"),
|
||||
config.ethEnable);
|
||||
gtk_toggle_button_set_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_HDDENABLED"),
|
||||
config.hddEnable);
|
||||
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
void OnOk() {
|
||||
|
||||
char* ptr = gtk_combo_box_text_get_active_text((GtkComboBoxText *)gtk_builder_get_object(builder,"IDC_ETHDEV"));
|
||||
strcpy(config.Eth, ptr);
|
||||
|
||||
strcpy(config.Hdd, gtk_entry_get_text ((GtkEntry *)gtk_builder_get_object(builder,"IDC_HDDFILE")));
|
||||
|
||||
config.ethEnable = gtk_toggle_button_get_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_ETHENABLED"));
|
||||
config.hddEnable = gtk_toggle_button_get_active ((GtkToggleButton *)gtk_builder_get_object(builder,"IDC_HDDENABLED"));
|
||||
|
||||
SaveConf();
|
||||
|
||||
}
|
||||
|
||||
/* Simple GTK+2 variant of gtk_builder_add_from_resource() */
|
||||
static guint builder_add_from_resource(GtkBuilder *builder
|
||||
, const gchar *resource_path
|
||||
, GError **error)
|
||||
{
|
||||
GBytes *data;
|
||||
const gchar *buffer;
|
||||
gsize buffer_length;
|
||||
guint ret;
|
||||
|
||||
g_assert(error && *error == NULL);
|
||||
|
||||
data = g_resources_lookup_data(resource_path, G_RESOURCE_LOOKUP_FLAGS_NONE, error);
|
||||
if (data == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer_length = 0;
|
||||
buffer = (const gchar *)g_bytes_get_data(data, &buffer_length);
|
||||
g_assert(buffer != NULL);
|
||||
|
||||
ret = gtk_builder_add_from_string(builder, buffer, buffer_length, error);
|
||||
|
||||
g_bytes_unref(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT_C_(void)
|
||||
DEV9configure() {
|
||||
|
||||
gtk_init (NULL, NULL);
|
||||
GError *error = NULL;
|
||||
builder = gtk_builder_new();
|
||||
if (!builder_add_from_resource(builder, "/net/pcsx2/dev9ghzdrk/Linux/dev9ghzdrk.ui", &error)) {
|
||||
g_warning("Could not build config ui: %s", error->message);
|
||||
g_error_free(error);
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
}
|
||||
GtkDialog *dlg = GTK_DIALOG (gtk_builder_get_object(builder, "IDD_CONFDLG"));
|
||||
OnInitDialog();
|
||||
gint result = gtk_dialog_run (dlg);
|
||||
switch(result) {
|
||||
case -5: //IDOK
|
||||
OnOk();
|
||||
break;
|
||||
case -6: //IDCANCEL
|
||||
break;
|
||||
}
|
||||
gtk_widget_hide (GTK_WIDGET(dlg));
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((constructor)) DllMain() {
|
||||
//gtk_builder_add_from_file(builder, "dev9ghzdrk.ui", NULL);
|
||||
//builder = gtk_build_new_from_resource( "/net/pcsx2/dev9ghzdrk/dev9ghzdrk.ui" );
|
||||
}
|
||||
|
||||
NetAdapter* GetNetAdapter()
|
||||
{
|
||||
NetAdapter* na;
|
||||
na = new PCAPAdapter();
|
||||
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
delete na;
|
||||
return 0;
|
||||
}
|
||||
return na;
|
||||
}
|
||||
s32 _DEV9open()
|
||||
{
|
||||
NetAdapter* na=GetNetAdapter();
|
||||
if (!na)
|
||||
{
|
||||
emu_printf("Failed to GetNetAdapter()\n");
|
||||
config.ethEnable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNet(na);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _DEV9close() {
|
||||
TermNet();
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.24"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkDialog" id="IDD_CONFDLG">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">HDD Configure</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="IDOK">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="IDCANCEL">
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Dev9 Type </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="IDC_BAYTYPE">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="has_entry">True</property>
|
||||
<property name="entry_text_column">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="expander1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="IDC_ETHENABLED">
|
||||
<property name="label" translatable="yes">Enabled</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Ethernet Device </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="IDC_ETHDEV">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="has_entry">True</property>
|
||||
<property name="entry_text_column">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Ethernet</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkExpander" id="expander2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="IDC_HDDENABLED">
|
||||
<property name="label" translatable="yes">ENABLED</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">HDD File </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="IDC_HDDFILE">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Hard Disk Drive (not yet properly implemented</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">IDOK</action-widget>
|
||||
<action-widget response="-6">IDCANCEL</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,79 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "net.h"
|
||||
#include "../DEV9.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
NetAdapter* nif;
|
||||
pthread_t rx_thread;
|
||||
|
||||
volatile bool RxRunning=false;
|
||||
|
||||
void *NetRxThread(void *arg)
|
||||
{
|
||||
NetPacket tmp;
|
||||
while(RxRunning)
|
||||
{
|
||||
while(rx_fifo_can_rx() && nif->recv(&tmp))
|
||||
{
|
||||
rx_process(&tmp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tx_put(NetPacket* pkt)
|
||||
{
|
||||
nif->send(pkt);
|
||||
//pkt must be copied if its not processed by here, since it can be allocated on the callers stack
|
||||
}
|
||||
|
||||
void InitNet(NetAdapter* ad)
|
||||
{
|
||||
nif=ad;
|
||||
RxRunning=true;
|
||||
|
||||
pthread_attr_t thAttr;
|
||||
int policy = 0;
|
||||
int max_prio_for_policy = 0;
|
||||
|
||||
|
||||
rx_thread = pthread_create(&rx_thread, NULL, NetRxThread, NULL);
|
||||
pthread_attr_init(&thAttr);
|
||||
pthread_attr_getschedpolicy(&thAttr, &policy);
|
||||
max_prio_for_policy = sched_get_priority_max(policy);
|
||||
|
||||
|
||||
pthread_setschedprio(rx_thread, max_prio_for_policy);
|
||||
pthread_attr_destroy(&thAttr);
|
||||
}
|
||||
|
||||
void TermNet()
|
||||
{
|
||||
if(RxRunning)
|
||||
{
|
||||
RxRunning = false;
|
||||
emu_printf("Waiting for RX-net thread to terminate..");
|
||||
pthread_join(rx_thread,NULL);
|
||||
emu_printf(".done\n");
|
||||
|
||||
delete nif;
|
||||
}
|
||||
}
|
|
@ -1,699 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PS2EDEFS_H__
|
||||
#define __PS2EDEFS_H__
|
||||
|
||||
/*
|
||||
* PS2E Definitions v0.5.5 (beta)
|
||||
*
|
||||
* Author: linuzappz@hotmail.com
|
||||
* shadowpcsx2@yahoo.gr
|
||||
* florinsasu@hotmail.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Notes:
|
||||
* Since this is still beta things may change.
|
||||
|
||||
* OSflags:
|
||||
__linux__ (linux OS)
|
||||
_WIN32 (win32 OS)
|
||||
|
||||
* common return values (for ie. GSinit):
|
||||
0 - success
|
||||
-1 - error
|
||||
|
||||
* reserved keys:
|
||||
F1 to F10 are reserved for the emulator
|
||||
|
||||
* plugins should NOT change the current
|
||||
working directory.
|
||||
(on win32, add flag OFN_NOCHANGEDIR for
|
||||
GetOpenFileName)
|
||||
|
||||
*/
|
||||
|
||||
#include "PS2Etypes.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#define CALLBACK
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* common defines */
|
||||
|
||||
#if defined(GSdefs) || defined(PADdefs) || \
|
||||
defined(SPU2defs)|| defined(CDVDdefs)
|
||||
#define COMMONdefs
|
||||
#endif
|
||||
|
||||
// PS2EgetLibType returns (may be OR'd)
|
||||
#define PS2E_LT_GS 0x01
|
||||
#define PS2E_LT_PAD 0x02
|
||||
#define PS2E_LT_SPU2 0x04
|
||||
#define PS2E_LT_CDVD 0x08
|
||||
#define PS2E_LT_DEV9 0x10
|
||||
#define PS2E_LT_USB 0x20
|
||||
#define PS2E_LT_FIREWIRE 0x40
|
||||
|
||||
// PS2EgetLibVersion2 (high 16 bits)
|
||||
#define PS2E_GS_VERSION 0x0005
|
||||
#define PS2E_PAD_VERSION 0x0002
|
||||
#define PS2E_SPU2_VERSION 0x0004
|
||||
#define PS2E_CDVD_VERSION 0x0003
|
||||
#define PS2E_DEV9_VERSION 0x0003
|
||||
#define PS2E_USB_VERSION 0x0003
|
||||
#define PS2E_FIREWIRE_VERSION 0x0002
|
||||
#ifdef COMMONdefs
|
||||
|
||||
u32 CALLBACK PS2EgetLibType(void);
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type);
|
||||
char* CALLBACK PS2EgetLibName(void);
|
||||
|
||||
#endif
|
||||
|
||||
// key values:
|
||||
/* key values must be OS dependant:
|
||||
win32: the VK_XXX will be used (WinUser)
|
||||
linux: the XK_XXX will be used (XFree86)
|
||||
*/
|
||||
|
||||
// event values:
|
||||
#define KEYPRESS 1
|
||||
#define KEYRELEASE 2
|
||||
|
||||
typedef struct {
|
||||
u32 key;
|
||||
u32 event;
|
||||
} keyEvent;
|
||||
|
||||
typedef struct { // NOT bcd coded
|
||||
u8 minute;
|
||||
u8 second;
|
||||
u8 frame;
|
||||
u8 type;
|
||||
} cdvdTD;
|
||||
|
||||
typedef struct {
|
||||
u8 strack; //number of the first track (usualy 1)
|
||||
u8 etrack; //number of the last track
|
||||
} cdvdTN;
|
||||
|
||||
// CDVDreadTrack mode values:
|
||||
#define CDVD_MODE_2352 0 // full 2352 bytes
|
||||
#define CDVD_MODE_2340 1 // skip sync (12) bytes
|
||||
#define CDVD_MODE_2328 2 // skip sync+head+sub (24) bytes
|
||||
#define CDVD_MODE_2048 3 // skip sync+head+sub (24) bytes
|
||||
#define CDVD_MODE_2368 4 // full 2352 bytes + 16 subq
|
||||
|
||||
// CDVDgetType returns:
|
||||
#define CDVD_TYPE_ILLEGAL 0xff // Illegal Disc
|
||||
#define CDVD_TYPE_DVDV 0xfe // DVD Video
|
||||
#define CDVD_TYPE_CDDA 0xfd // Audio CD
|
||||
#define CDVD_TYPE_PS2DVD 0x14 // PS2 DVD
|
||||
#define CDVD_TYPE_PS2CDDA 0x13 // PS2 CD (with audio)
|
||||
#define CDVD_TYPE_PS2CD 0x12 // PS2 CD
|
||||
#define CDVD_TYPE_PSCDDA 0x11 // PS CD (with audio)
|
||||
#define CDVD_TYPE_PSCD 0x10 // PS CD
|
||||
#define CDVD_TYPE_UNKNOWN 0x05 // Unknown
|
||||
#define CDVD_TYPE_DETCTDVDD 0x04 // Detecting Dvd Dual Sided
|
||||
#define CDVD_TYPE_DETCTDVDS 0x03 // Detecting Dvd Single Sided
|
||||
#define CDVD_TYPE_DETCTCD 0x02 // Detecting Cd
|
||||
#define CDVD_TYPE_DETCT 0x01 // Detecting
|
||||
#define CDVD_TYPE_NODISC 0x00 // No Disc
|
||||
|
||||
// CDVDgetTrayStatus returns:
|
||||
#define CDVD_TRAY_CLOSE 0x00
|
||||
#define CDVD_TRAY_OPEN 0x01
|
||||
|
||||
// cdvdLoc:track type
|
||||
#define CDVD_AUDIO_TRACK 0x01
|
||||
#define CDVD_MODE1_TRACK 0x41
|
||||
#define CDVD_MODE2_TRACK 0x61
|
||||
|
||||
#define CDVD_AUDIO_MASK 0x00
|
||||
#define CDVD_DATA_MASK 0x40
|
||||
// CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel)
|
||||
|
||||
typedef void (*DEV9callback)(int cycles);
|
||||
typedef int (*DEV9handler)(void);
|
||||
|
||||
typedef void (*USBcallback)(int cycles);
|
||||
typedef int (*USBhandler)(void);
|
||||
|
||||
// freeze modes:
|
||||
#define FREEZE_LOAD 0
|
||||
#define FREEZE_SAVE 1
|
||||
#define FREEZE_SIZE 2
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
s8 *data;
|
||||
} freezeData;
|
||||
|
||||
typedef struct {
|
||||
char name[8];
|
||||
void *common;
|
||||
} GSdriverInfo;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef struct { // unsupported values must be set to zero
|
||||
HWND hWnd;
|
||||
HMENU hMenu;
|
||||
HWND hStatusWnd;
|
||||
} winInfo;
|
||||
#endif
|
||||
|
||||
/* GS plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef GSdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK GSinit();
|
||||
s32 CALLBACK GSopen(void *pDsp, char *Title);
|
||||
void CALLBACK GSclose();
|
||||
void CALLBACK GSshutdown();
|
||||
void CALLBACK GSvsync();
|
||||
void CALLBACK GSgifTransfer1(u32 *pMem);
|
||||
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size);
|
||||
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size);
|
||||
void CALLBACK GSwrite32(u32 mem, u32 value);
|
||||
void CALLBACK GSwrite64(u32 mem, u64 value);
|
||||
u32 CALLBACK GSread32(u32 mem);
|
||||
u64 CALLBACK GSread64(u32 mem);
|
||||
void CALLBACK GSreadFIFO(u64 *mem);
|
||||
|
||||
// extended funcs
|
||||
|
||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||
void CALLBACK GSkeyEvent(keyEvent *ev);
|
||||
void CALLBACK GSmakeSnapshot(char *path);
|
||||
void CALLBACK GSirqCallback(void (*callback)());
|
||||
void CALLBACK GSprintf(int timeout, char *fmt, ...);
|
||||
void CALLBACK GSgetDriverInfo(GSdriverInfo *info);
|
||||
#ifdef _WIN32
|
||||
s32 CALLBACK GSsetWindowInfo(winInfo *info);
|
||||
#endif
|
||||
s32 CALLBACK GSfreeze(int mode, freezeData *data);
|
||||
void CALLBACK GSconfigure();
|
||||
void CALLBACK GSabout();
|
||||
s32 CALLBACK GStest();
|
||||
|
||||
#endif
|
||||
|
||||
/* PAD plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef PADdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK PADinit(u32 flags);
|
||||
s32 CALLBACK PADopen(void *pDsp);
|
||||
void CALLBACK PADclose();
|
||||
void CALLBACK PADshutdown();
|
||||
// PADkeyEvent is called every vsync (return NULL if no event)
|
||||
keyEvent* CALLBACK PADkeyEvent();
|
||||
u8 CALLBACK PADstartPoll(int pad);
|
||||
u8 CALLBACK PADpoll(u8 value);
|
||||
// returns: 1 if supported pad1
|
||||
// 2 if supported pad2
|
||||
// 3 if both are supported
|
||||
u32 CALLBACK PADquery();
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK PADgsDriverInfo(GSdriverInfo *info);
|
||||
void CALLBACK PADconfigure();
|
||||
void CALLBACK PADabout();
|
||||
s32 CALLBACK PADtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* SPU2 plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef SPU2defs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK SPU2init();
|
||||
s32 CALLBACK SPU2open(void *pDsp);
|
||||
void CALLBACK SPU2close();
|
||||
void CALLBACK SPU2shutdown();
|
||||
void CALLBACK SPU2write(u32 mem, u16 value);
|
||||
u16 CALLBACK SPU2read(u32 mem);
|
||||
void CALLBACK SPU2readDMA4Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2writeDMA4Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2interruptDMA4();
|
||||
void CALLBACK SPU2readDMA7Mem(u16* pMem, int size);
|
||||
void CALLBACK SPU2writeDMA7Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2interruptDMA7();
|
||||
void CALLBACK SPU2irqCallback(void (*callback)());
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK SPU2async(u32 cycles);
|
||||
s32 CALLBACK SPU2freeze(int mode, freezeData *data);
|
||||
void CALLBACK SPU2configure();
|
||||
void CALLBACK SPU2about();
|
||||
s32 CALLBACK SPU2test();
|
||||
|
||||
#endif
|
||||
|
||||
/* CDVD plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef CDVDdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK CDVDinit();
|
||||
s32 CALLBACK CDVDopen();
|
||||
void CALLBACK CDVDclose();
|
||||
void CALLBACK CDVDshutdown();
|
||||
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
|
||||
|
||||
// return can be NULL (for async modes)
|
||||
u8* CALLBACK CDVDgetBuffer();
|
||||
|
||||
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer); //disk information
|
||||
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
||||
s32 CALLBACK CDVDgetType(); //CDVD_TYPE_xxxx
|
||||
s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK CDVDconfigure();
|
||||
void CALLBACK CDVDabout();
|
||||
s32 CALLBACK CDVDtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* DEV9 plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef DEV9defs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK DEV9init();
|
||||
s32 CALLBACK DEV9open(void *pDsp);
|
||||
void CALLBACK DEV9close();
|
||||
void CALLBACK DEV9shutdown();
|
||||
u8 CALLBACK DEV9read8(u32 addr);
|
||||
u16 CALLBACK DEV9read16(u32 addr);
|
||||
u32 CALLBACK DEV9read32(u32 addr);
|
||||
void CALLBACK DEV9write8(u32 addr, u8 value);
|
||||
void CALLBACK DEV9write16(u32 addr, u16 value);
|
||||
void CALLBACK DEV9write32(u32 addr, u32 value);
|
||||
void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size);
|
||||
void CALLBACK DEV9writeDMA8Mem(u32 *pMem, int size);
|
||||
// cycles = IOP cycles before calling callback,
|
||||
// if callback returns 1 the irq is triggered, else not
|
||||
void CALLBACK DEV9irqCallback(DEV9callback callback);
|
||||
DEV9handler CALLBACK DEV9irqHandler(void);
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK DEV9freeze(int mode, freezeData *data);
|
||||
void CALLBACK DEV9configure();
|
||||
void CALLBACK DEV9about();
|
||||
s32 CALLBACK DEV9test();
|
||||
|
||||
#endif
|
||||
|
||||
/* USB plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef USBdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK USBinit();
|
||||
s32 CALLBACK USBopen(void *pDsp);
|
||||
void CALLBACK USBclose();
|
||||
void CALLBACK USBshutdown();
|
||||
u8 CALLBACK USBread8(u32 addr);
|
||||
u16 CALLBACK USBread16(u32 addr);
|
||||
u32 CALLBACK USBread32(u32 addr);
|
||||
void CALLBACK USBwrite8(u32 addr, u8 value);
|
||||
void CALLBACK USBwrite16(u32 addr, u16 value);
|
||||
void CALLBACK USBwrite32(u32 addr, u32 value);
|
||||
// cycles = IOP cycles before calling callback,
|
||||
// if callback returns 1 the irq is triggered, else not
|
||||
void CALLBACK USBirqCallback(USBcallback callback);
|
||||
USBhandler CALLBACK USBirqHandler(void);
|
||||
void CALLBACK USBsetRAM(void *mem);
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK USBfreeze(int mode, freezeData *data);
|
||||
void CALLBACK USBconfigure();
|
||||
void CALLBACK USBabout();
|
||||
s32 CALLBACK USBtest();
|
||||
|
||||
#endif
|
||||
/* Firewire plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef FIREWIREdefs
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK FireWireinit();
|
||||
s32 CALLBACK FireWireopen(void *pDsp);
|
||||
void CALLBACK FireWireclose();
|
||||
void CALLBACK FireWireshutdown();
|
||||
u32 CALLBACK FireWireread32(u32 addr);
|
||||
void CALLBACK FireWirewrite32(u32 addr, u32 value);
|
||||
void CALLBACK FireWireirqCallback(void (*callback)());
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK FireWirefreeze(int mode, freezeData *data);
|
||||
void CALLBACK FireWireconfigure();
|
||||
void CALLBACK FireWireabout();
|
||||
s32 CALLBACK FireWiretest();
|
||||
#endif
|
||||
|
||||
// might be useful for emulators
|
||||
#ifdef PLUGINtypedefs
|
||||
|
||||
typedef u32 (CALLBACK* _PS2EgetLibType)(void);
|
||||
typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type);
|
||||
typedef char*(CALLBACK* _PS2EgetLibName)(void);
|
||||
|
||||
// GS
|
||||
typedef s32 (CALLBACK* _GSinit)();
|
||||
typedef s32 (CALLBACK* _GSopen)(void *pDsp, char *Title);
|
||||
typedef void (CALLBACK* _GSclose)();
|
||||
typedef void (CALLBACK* _GSshutdown)();
|
||||
typedef void (CALLBACK* _GSvsync)();
|
||||
typedef void (CALLBACK* _GSwrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _GSwrite64)(u32 mem, u64 value);
|
||||
typedef u32 (CALLBACK* _GSread32)(u32 mem);
|
||||
typedef u64 (CALLBACK* _GSread64)(u32 mem);
|
||||
typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem);
|
||||
typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size);
|
||||
typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size);
|
||||
typedef void (CALLBACK* _GSreadFIFO)(u64 *pMem);
|
||||
|
||||
typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev);
|
||||
typedef void (CALLBACK* _GSirqCallback)(void (*callback)());
|
||||
typedef void (CALLBACK* _GSprintf)(int timeout, char *fmt, ...);
|
||||
typedef void (CALLBACK* _GSgetDriverInfo)(GSdriverInfo *info);
|
||||
#ifdef _WIN32
|
||||
typedef s32 (CALLBACK* _GSsetWindowInfo)(winInfo *info);
|
||||
#endif
|
||||
typedef void (CALLBACK* _GSmakeSnapshot)(char *path);
|
||||
typedef s32 (CALLBACK* _GSfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _GSconfigure)();
|
||||
typedef s32 (CALLBACK* _GStest)();
|
||||
typedef void (CALLBACK* _GSabout)();
|
||||
|
||||
// PAD
|
||||
typedef s32 (CALLBACK* _PADinit)(u32 flags);
|
||||
typedef s32 (CALLBACK* _PADopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _PADclose)();
|
||||
typedef void (CALLBACK* _PADshutdown)();
|
||||
typedef keyEvent* (CALLBACK* _PADkeyEvent)();
|
||||
typedef u8 (CALLBACK* _PADstartPoll)(int pad);
|
||||
typedef u8 (CALLBACK* _PADpoll)(u8 value);
|
||||
typedef u32 (CALLBACK* _PADquery)();
|
||||
|
||||
typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
|
||||
typedef void (CALLBACK* _PADconfigure)();
|
||||
typedef s32 (CALLBACK* _PADtest)();
|
||||
typedef void (CALLBACK* _PADabout)();
|
||||
|
||||
// SPU2
|
||||
typedef s32 (CALLBACK* _SPU2init)();
|
||||
typedef s32 (CALLBACK* _SPU2open)(void *pDsp);
|
||||
typedef void (CALLBACK* _SPU2close)();
|
||||
typedef void (CALLBACK* _SPU2shutdown)();
|
||||
typedef void (CALLBACK* _SPU2write)(u32 mem, u16 value);
|
||||
typedef u16 (CALLBACK* _SPU2read)(u32 mem);
|
||||
typedef void (CALLBACK* _SPU2readDMA4Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2writeDMA4Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2interruptDMA4)();
|
||||
typedef void (CALLBACK* _SPU2readDMA7Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2writeDMA7Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2interruptDMA7)();
|
||||
typedef void (CALLBACK* _SPU2irqCallback)(void (*callback)());
|
||||
|
||||
typedef void (CALLBACK* _SPU2async)(u32 cycles);
|
||||
typedef s32 (CALLBACK* _SPU2freeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _SPU2configure)();
|
||||
typedef s32 (CALLBACK* _SPU2test)();
|
||||
typedef void (CALLBACK* _SPU2about)();
|
||||
|
||||
// CDVD
|
||||
typedef s32 (CALLBACK* _CDVDinit)();
|
||||
typedef s32 (CALLBACK* _CDVDopen)();
|
||||
typedef void (CALLBACK* _CDVDclose)();
|
||||
typedef void (CALLBACK* _CDVDshutdown)();
|
||||
typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode);
|
||||
typedef u8* (CALLBACK* _CDVDgetBuffer)();
|
||||
typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetType)();
|
||||
typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
|
||||
|
||||
typedef void (CALLBACK* _CDVDconfigure)();
|
||||
typedef s32 (CALLBACK* _CDVDtest)();
|
||||
typedef void (CALLBACK* _CDVDabout)();
|
||||
|
||||
// DEV9
|
||||
typedef s32 (CALLBACK* _DEV9init)();
|
||||
typedef s32 (CALLBACK* _DEV9open)(void *pDsp);
|
||||
typedef void (CALLBACK* _DEV9close)();
|
||||
typedef void (CALLBACK* _DEV9shutdown)();
|
||||
typedef u8 (CALLBACK* _DEV9read8)(u32 mem);
|
||||
typedef u16 (CALLBACK* _DEV9read16)(u32 mem);
|
||||
typedef u32 (CALLBACK* _DEV9read32)(u32 mem);
|
||||
typedef void (CALLBACK* _DEV9write8)(u32 mem, u8 value);
|
||||
typedef void (CALLBACK* _DEV9write16)(u32 mem, u16 value);
|
||||
typedef void (CALLBACK* _DEV9write32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _DEV9readDMA8Mem)(u32 *pMem, int size);
|
||||
typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
|
||||
typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
|
||||
typedef DEV9handler (CALLBACK* _DEV9irqHandler)(void);
|
||||
|
||||
typedef s32 (CALLBACK* _DEV9freeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _DEV9configure)();
|
||||
typedef s32 (CALLBACK* _DEV9test)();
|
||||
typedef void (CALLBACK* _DEV9about)();
|
||||
|
||||
// USB
|
||||
typedef s32 (CALLBACK* _USBinit)();
|
||||
typedef s32 (CALLBACK* _USBopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _USBclose)();
|
||||
typedef void (CALLBACK* _USBshutdown)();
|
||||
typedef u8 (CALLBACK* _USBread8)(u32 mem);
|
||||
typedef u16 (CALLBACK* _USBread16)(u32 mem);
|
||||
typedef u32 (CALLBACK* _USBread32)(u32 mem);
|
||||
typedef void (CALLBACK* _USBwrite8)(u32 mem, u8 value);
|
||||
typedef void (CALLBACK* _USBwrite16)(u32 mem, u16 value);
|
||||
typedef void (CALLBACK* _USBwrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _USBirqCallback)(USBcallback callback);
|
||||
typedef USBhandler (CALLBACK* _USBirqHandler)(void);
|
||||
typedef void (CALLBACK* _USBsetRAM)(void *mem);
|
||||
|
||||
typedef s32 (CALLBACK* _USBfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _USBconfigure)();
|
||||
typedef s32 (CALLBACK* _USBtest)();
|
||||
typedef void (CALLBACK* _USBabout)();
|
||||
|
||||
//FireWire
|
||||
typedef s32 (CALLBACK* _FireWireinit)();
|
||||
typedef s32 (CALLBACK* _FireWireopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _FireWireclose)();
|
||||
typedef void (CALLBACK* _FireWireshutdown)();
|
||||
typedef u32 (CALLBACK* _FireWireread32)(u32 mem);
|
||||
typedef void (CALLBACK* _FireWirewrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _FireWireirqCallback)(void (*callback)());
|
||||
|
||||
typedef s32 (CALLBACK* _FireWirefreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _FireWireconfigure)();
|
||||
typedef s32 (CALLBACK* _FireWiretest)();
|
||||
typedef void (CALLBACK* _FireWireabout)();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PLUGINfuncs
|
||||
|
||||
// GS
|
||||
_GSinit GSinit;
|
||||
_GSopen GSopen;
|
||||
_GSclose GSclose;
|
||||
_GSshutdown GSshutdown;
|
||||
_GSvsync GSvsync;
|
||||
_GSwrite32 GSwrite32;
|
||||
_GSwrite64 GSwrite64;
|
||||
_GSread32 GSread32;
|
||||
_GSread64 GSread64;
|
||||
_GSgifTransfer1 GSgifTransfer1;
|
||||
_GSgifTransfer2 GSgifTransfer2;
|
||||
_GSgifTransfer3 GSgifTransfer3;
|
||||
_GSreadFIFO GSreadFIFO;
|
||||
|
||||
_GSkeyEvent GSkeyEvent;
|
||||
_GSmakeSnapshot GSmakeSnapshot;
|
||||
_GSirqCallback GSirqCallback;
|
||||
_GSprintf GSprintf;
|
||||
_GSgetDriverInfo GSgetDriverInfo;
|
||||
#ifdef _WIN32
|
||||
_GSsetWindowInfo GSsetWindowInfo;
|
||||
#endif
|
||||
_GSfreeze GSfreeze;
|
||||
_GSconfigure GSconfigure;
|
||||
_GStest GStest;
|
||||
_GSabout GSabout;
|
||||
|
||||
// PAD1
|
||||
_PADinit PAD1init;
|
||||
_PADopen PAD1open;
|
||||
_PADclose PAD1close;
|
||||
_PADshutdown PAD1shutdown;
|
||||
_PADkeyEvent PAD1keyEvent;
|
||||
_PADstartPoll PAD1startPoll;
|
||||
_PADpoll PAD1poll;
|
||||
_PADquery PAD1query;
|
||||
|
||||
_PADgsDriverInfo PAD1gsDriverInfo;
|
||||
_PADconfigure PAD1configure;
|
||||
_PADtest PAD1test;
|
||||
_PADabout PAD1about;
|
||||
|
||||
// PAD2
|
||||
_PADinit PAD2init;
|
||||
_PADopen PAD2open;
|
||||
_PADclose PAD2close;
|
||||
_PADshutdown PAD2shutdown;
|
||||
_PADkeyEvent PAD2keyEvent;
|
||||
_PADstartPoll PAD2startPoll;
|
||||
_PADpoll PAD2poll;
|
||||
_PADquery PAD2query;
|
||||
|
||||
_PADgsDriverInfo PAD2gsDriverInfo;
|
||||
_PADconfigure PAD2configure;
|
||||
_PADtest PAD2test;
|
||||
_PADabout PAD2about;
|
||||
|
||||
// SPU2
|
||||
_SPU2init SPU2init;
|
||||
_SPU2open SPU2open;
|
||||
_SPU2close SPU2close;
|
||||
_SPU2shutdown SPU2shutdown;
|
||||
_SPU2write SPU2write;
|
||||
_SPU2read SPU2read;
|
||||
_SPU2readDMA4Mem SPU2readDMA4Mem;
|
||||
_SPU2writeDMA4Mem SPU2writeDMA4Mem;
|
||||
_SPU2interruptDMA4 SPU2interruptDMA4;
|
||||
_SPU2readDMA7Mem SPU2readDMA7Mem;
|
||||
_SPU2writeDMA7Mem SPU2writeDMA7Mem;
|
||||
_SPU2interruptDMA7 SPU2interruptDMA7;
|
||||
_SPU2irqCallback SPU2irqCallback;
|
||||
|
||||
_SPU2async SPU2async;
|
||||
_SPU2freeze SPU2freeze;
|
||||
_SPU2configure SPU2configure;
|
||||
_SPU2test SPU2test;
|
||||
_SPU2about SPU2about;
|
||||
|
||||
// CDVD
|
||||
_CDVDinit CDVDinit;
|
||||
_CDVDopen CDVDopen;
|
||||
_CDVDclose CDVDclose;
|
||||
_CDVDshutdown CDVDshutdown;
|
||||
_CDVDreadTrack CDVDreadTrack;
|
||||
_CDVDgetBuffer CDVDgetBuffer;
|
||||
_CDVDgetTN CDVDgetTN;
|
||||
_CDVDgetTD CDVDgetTD;
|
||||
_CDVDgetType CDVDgetType;
|
||||
_CDVDgetTrayStatus CDVDgetTrayStatus;
|
||||
|
||||
_CDVDconfigure CDVDconfigure;
|
||||
_CDVDtest CDVDtest;
|
||||
_CDVDabout CDVDabout;
|
||||
|
||||
// DEV9
|
||||
_DEV9init DEV9init;
|
||||
_DEV9open DEV9open;
|
||||
_DEV9close DEV9close;
|
||||
_DEV9shutdown DEV9shutdown;
|
||||
_DEV9read8 DEV9read8;
|
||||
_DEV9read16 DEV9read16;
|
||||
_DEV9read32 DEV9read32;
|
||||
_DEV9write8 DEV9write8;
|
||||
_DEV9write16 DEV9write16;
|
||||
_DEV9write32 DEV9write32;
|
||||
_DEV9readDMA8Mem DEV9readDMA8Mem;
|
||||
_DEV9writeDMA8Mem DEV9writeDMA8Mem;
|
||||
_DEV9irqCallback DEV9irqCallback;
|
||||
_DEV9irqHandler DEV9irqHandler;
|
||||
|
||||
_DEV9configure DEV9configure;
|
||||
_DEV9freeze DEV9freeze;
|
||||
_DEV9test DEV9test;
|
||||
_DEV9about DEV9about;
|
||||
|
||||
// USB
|
||||
_USBinit USBinit;
|
||||
_USBopen USBopen;
|
||||
_USBclose USBclose;
|
||||
_USBshutdown USBshutdown;
|
||||
_USBread8 USBread8;
|
||||
_USBread16 USBread16;
|
||||
_USBread32 USBread32;
|
||||
_USBwrite8 USBwrite8;
|
||||
_USBwrite16 USBwrite16;
|
||||
_USBwrite32 USBwrite32;
|
||||
_USBirqCallback USBirqCallback;
|
||||
_USBirqHandler USBirqHandler;
|
||||
_USBsetRAM USBsetRAM;
|
||||
|
||||
_USBconfigure USBconfigure;
|
||||
_USBfreeze USBfreeze;
|
||||
_USBtest USBtest;
|
||||
_USBabout USBabout;
|
||||
|
||||
// FireWire
|
||||
_FireWireinit FireWireinit;
|
||||
_FireWireopen FireWireopen;
|
||||
_FireWireclose FireWireclose;
|
||||
_FireWireshutdown FireWireshutdown;
|
||||
_FireWireread32 FireWireread32;
|
||||
_FireWirewrite32 FireWirewrite32;
|
||||
_FireWireirqCallback FireWireirqCallback;
|
||||
|
||||
_FireWireconfigure FireWireconfigure;
|
||||
_FireWirefreeze FireWirefreeze;
|
||||
_FireWiretest FireWiretest;
|
||||
_FireWireabout FireWireabout;
|
||||
#endif
|
||||
|
||||
#endif /* __PS2EDEFS_H__ */
|
|
@ -63,27 +63,21 @@
|
|||
<ClCompile Include="..\pcap_io.cpp" />
|
||||
<ClCompile Include="Config.cpp" />
|
||||
<ClCompile Include="Win32.cpp" />
|
||||
<ClCompile Include="smap.cpp" />
|
||||
<ClCompile Include="..\smap.cpp" />
|
||||
<ClCompile Include="net.cpp" />
|
||||
<ClCompile Include="tap-win32.cpp" />
|
||||
<ClCompile Include="icmp.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="socket_io.cpp">
|
||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DEV9ghzdrk.def" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="mtfifo.h" />
|
||||
<ClInclude Include="smap.h" />
|
||||
<ClInclude Include="net.h" />
|
||||
<ClInclude Include="pcap_io.h" />
|
||||
<ClInclude Include="..\smap.h" />
|
||||
<ClInclude Include="..\net.h" />
|
||||
<ClInclude Include="..\pcap_io.h" />
|
||||
<ClInclude Include="tap.h" />
|
||||
<ClInclude Include="..\DEV9.h" />
|
||||
<ClInclude Include="..\PS2Edefs.h" />
|
||||
<ClInclude Include="PS2Edefs.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="DEV9ghzdrk.rc" />
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "Config.h"
|
||||
#include "..\Config.h"
|
||||
#include "resource.h"
|
||||
#include "..\DEV9.h"
|
||||
#include "pcap.h"
|
||||
#include "pcap_io.h"
|
||||
#include "net.h"
|
||||
#include "..\pcap_io.h"
|
||||
#include "..\net.h"
|
||||
#include "tap.h"
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
@ -48,17 +48,14 @@ void OnInitDialog(HWND hW) {
|
|||
|
||||
ComboBox_AddString(GetDlgItem(hW, IDC_BAYTYPE), "Expansion");
|
||||
ComboBox_AddString(GetDlgItem(hW, IDC_BAYTYPE), "PC Card");
|
||||
for (int j=0;j<2;j++)
|
||||
{
|
||||
for (int i=0; i<pcap_io_get_dev_num(); i++) {
|
||||
dev = pcap_io_get_dev_desc(i,j);
|
||||
dev = pcap_io_get_dev_desc(i);
|
||||
int itm=ComboBox_AddString(GetDlgItem(hW, IDC_ETHDEV), dev);
|
||||
ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV),itm,strdup(pcap_io_get_dev_name(i,j)));
|
||||
if (strcmp(pcap_io_get_dev_name(i,j), config.Eth) == 0) {
|
||||
ComboBox_SetItemData(GetDlgItem(hW, IDC_ETHDEV),itm,strdup(pcap_io_get_dev_name(i)));
|
||||
if (strcmp(pcap_io_get_dev_name(i), config.Eth) == 0) {
|
||||
ComboBox_SetCurSel(GetDlgItem(hW, IDC_ETHDEV), itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
vector<tap_adapter> * al=GetTapAdapters();
|
||||
for (size_t i=0; i<al->size(); i++) {
|
||||
|
||||
|
@ -146,7 +143,8 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void CALLBACK DEV9configure() {
|
||||
EXPORT_C_(void)
|
||||
DEV9configure() {
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_CONFIG),
|
||||
GetActiveWindow(),
|
||||
|
@ -154,7 +152,8 @@ void CALLBACK DEV9configure() {
|
|||
//SysMessage("Nothing to Configure");
|
||||
}
|
||||
|
||||
void CALLBACK DEV9about() {
|
||||
EXPORT_C_(void)
|
||||
DEV9about() {
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_ABOUT),
|
||||
GetActiveWindow(),
|
||||
|
@ -176,17 +175,7 @@ UINT DEV9ThreadProc() {
|
|||
NetAdapter* GetNetAdapter()
|
||||
{
|
||||
NetAdapter* na;
|
||||
if(config.Eth[0]=='p')
|
||||
{
|
||||
na = new PCAPAdapter();
|
||||
}
|
||||
else if (config.Eth[0]=='t')
|
||||
{
|
||||
na = new TAPAdapter();
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
na = (config.Eth[0]=='t') ? static_cast<NetAdapter*>(new TAPAdapter()) : static_cast<NetAdapter*>(new PCAPAdapter());
|
||||
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,120 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <icmpapi.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
struct pending_icmp_request
|
||||
{
|
||||
char ipaddress[4];
|
||||
HANDLE hEvent;
|
||||
DWORD sTick;
|
||||
DWORD timeOut; //ttl in ms
|
||||
DWORD replyBufferSize;
|
||||
char *replyBuffer;
|
||||
char *requestData;
|
||||
void *userdata;
|
||||
|
||||
pending_icmp_request()
|
||||
{
|
||||
memset(this,0,sizeof(pending_icmp_request));
|
||||
}
|
||||
|
||||
pending_icmp_request(pending_icmp_request&p)
|
||||
{
|
||||
memcpy(this,&p,sizeof(p));
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::list<pending_icmp_request> request_list;
|
||||
|
||||
request_list ping_list;
|
||||
|
||||
HANDLE hIP;
|
||||
|
||||
int icmp_init()
|
||||
{
|
||||
hIP = IcmpCreateFile();
|
||||
|
||||
if(hIP==INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void icmp_start(unsigned char *ipaddr, int ttl, void *data, int datasize, void *udata)
|
||||
{
|
||||
pending_icmp_request req;
|
||||
|
||||
req.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
req.sTick = GetTickCount();
|
||||
req.timeOut = ttl;
|
||||
|
||||
req.requestData = (char*)malloc(datasize);
|
||||
memcpy(req.requestData,data,datasize);
|
||||
|
||||
memcpy(req.ipaddress,ipaddr,4);
|
||||
|
||||
req.replyBufferSize = (sizeof(ICMP_ECHO_REPLY) + sizeof(datasize));
|
||||
req.replyBuffer = (char*)malloc(replyBufferSize);
|
||||
|
||||
req.userdata=udata;
|
||||
|
||||
ping_list.push_back(req);
|
||||
|
||||
IcmpSendEcho2(hIP,req.hEvent,NULL,NULL,*(DWORD*)ipaddr,req.requestData,58,
|
||||
NULL,req.replyBuffer,replyBufferSize,ttl);
|
||||
|
||||
}
|
||||
|
||||
int icmp_check_replies(char *ipaddress, void **udata)
|
||||
{
|
||||
for(request_list::iterator rit=ping_list.begin();rit!=ping_list.end();rit++)
|
||||
{
|
||||
if(WaitForSingleObject(rit->hEvent,0)==0) //handle is signaled, reply received.
|
||||
{
|
||||
if(IcmpParseReplies(rit->replyBuffer,rit->replyBufferSize)>0)
|
||||
{
|
||||
memcpy(ipaddress,rit->ipaddress,4);
|
||||
|
||||
ping_list.remove(rit);
|
||||
|
||||
return 1; //reply received
|
||||
}
|
||||
ResetEvent(rit->hEvent);
|
||||
}
|
||||
if(GetTickCount() >= (rit->sTick+rit->timeOut))
|
||||
{
|
||||
memcpy(ipaddress,rit->ipaddress,4);
|
||||
*udata = rit->userdata;
|
||||
|
||||
ping_list.remove(rit);
|
||||
|
||||
return 2; //timeout
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void icmp_close()
|
||||
{
|
||||
IcmpCloseHandle(hIP);
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "net.h"
|
||||
#include "..\net.h"
|
||||
#include "..\Dev9.h"
|
||||
|
||||
//mtfifo<NetPacket*> rx_fifo;
|
||||
|
|
|
@ -1,309 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <winsock2.h>
|
||||
extern "C" {
|
||||
#include "dev9.h"
|
||||
}
|
||||
#include <Iphlpapi.h>
|
||||
|
||||
#include "pcap_io.h"
|
||||
|
||||
#include <deque>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
//extern "C" int emu_printf(const char *fmt, ...);
|
||||
/*
|
||||
mac_address gateway_mac = { 0x76, 0x6D, 0x61, 0x63, 0x31, 0x32 };
|
||||
mac_address virtual_mac = { 0x76, 0x6D, 0x61, 0x63, 0x31, 0x31 };
|
||||
mac_address broadcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };*/
|
||||
|
||||
//mac_address host_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
ip_address virtual_gway_ip = { 192, 168, 1, 1};
|
||||
ip_address virtual_host_ip = { 192, 168, 1, 2};
|
||||
|
||||
char namebuff[256];
|
||||
|
||||
FILE*packet_log;
|
||||
|
||||
int pcap_io_running=0;
|
||||
|
||||
class packet_info
|
||||
{
|
||||
public:
|
||||
int length;
|
||||
s8 data[2048];
|
||||
|
||||
packet_info()
|
||||
{
|
||||
length=0;
|
||||
memset(data,0,2048);
|
||||
}
|
||||
|
||||
packet_info(const packet_info& pkt)
|
||||
{
|
||||
length=pkt.length;
|
||||
memcpy(data,pkt.data,length);
|
||||
}
|
||||
|
||||
packet_info(int l, void*d)
|
||||
{
|
||||
length=l;
|
||||
memcpy(data,d,l);
|
||||
}
|
||||
};
|
||||
|
||||
std::queue<packet_info> recv_queue;
|
||||
|
||||
|
||||
int ip_checksum(u16 *data, int length)
|
||||
{
|
||||
int n=(length+1)>>1;
|
||||
int s=0;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
int v=data[i];
|
||||
s=s+v;
|
||||
}
|
||||
s = (s&0xFFFF)+(s>>16);
|
||||
return s;
|
||||
}
|
||||
|
||||
//
|
||||
int pcap_io_init(char *adapter)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
|
||||
emu_printf(" * Socket IO: Initializing virtual gateway...",adapter);
|
||||
|
||||
WSAStartup(0x0200,&wsaData);
|
||||
|
||||
packet_log=fopen("logs/packet.log","w");
|
||||
|
||||
pcap_io_running=1;
|
||||
|
||||
emu_printf("Ok.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_io_send(void* packet, int plen)
|
||||
{
|
||||
emu_printf(" * Socket IO: Sending %d byte packet.\n",plen);
|
||||
|
||||
if(packet_log)
|
||||
{
|
||||
int i=0;
|
||||
int n=0;
|
||||
|
||||
fprintf(packet_log,"PACKET SEND: %d BYTES\n",plen);
|
||||
for(i=0,n=0;i<plen;i++)
|
||||
{
|
||||
fprintf(packet_log,"%02x",((unsigned char*)packet)[i]);
|
||||
n++;
|
||||
if(n==16)
|
||||
{
|
||||
fprintf(packet_log,"\n");
|
||||
n=0;
|
||||
}
|
||||
else
|
||||
fprintf(packet_log," ");
|
||||
}
|
||||
fprintf(packet_log,"\n");
|
||||
}
|
||||
|
||||
ethernet_header *eth = (ethernet_header*)packet;
|
||||
|
||||
if(mac_compare(eth->dst,broadcast_mac)==0) //broadcast packets
|
||||
{
|
||||
if(eth->protocol == 0x0608) //ARP
|
||||
{
|
||||
arp_packet *arp = (arp_packet*)((s8*)packet+sizeof(ethernet_header));
|
||||
if(arp->operation == 0x0100) //ARP request
|
||||
{
|
||||
if(ip_compare(arp->p_dst,virtual_gway_ip)==0) //it's trying to resolve the virtual gateway's mac addr
|
||||
{
|
||||
full_arp_packet p;
|
||||
p.header.src = gateway_mac;
|
||||
p.header.dst = eth->src;
|
||||
p.header.protocol = 0x0608;
|
||||
p.arp.h_addr_len=6;
|
||||
p.arp.h_dst = eth->src;
|
||||
p.arp.h_src = gateway_mac;
|
||||
p.arp.p_addr_len = 4;
|
||||
p.arp.p_dst = arp->p_src;
|
||||
p.arp.p_src = virtual_gway_ip;
|
||||
p.arp.protocol = 0x0008;
|
||||
p.arp.operation = 0x0200;
|
||||
|
||||
//packet_info pkt(sizeof(p),&p)
|
||||
recv_queue.push(packet_info(sizeof(p),&p));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mac_compare(eth->dst,gateway_mac)==0)
|
||||
{
|
||||
if(eth->protocol == 0x0008) //IP
|
||||
{
|
||||
ip_header *ip = (ip_header*)((s8*)packet+sizeof(ethernet_header));
|
||||
|
||||
if((ip->proto == 0x11) && (ip->dst.bytes[0]!=192)) //UDP (non-local)
|
||||
{
|
||||
//
|
||||
//if(ip->
|
||||
}
|
||||
else
|
||||
if(ip->proto == 0x01) //ICMP
|
||||
{
|
||||
if (ip_compare(ip->dst,virtual_gway_ip)==0) //PING to gateway
|
||||
{
|
||||
static u8 icmp_packet[1024];
|
||||
|
||||
memcpy(icmp_packet,packet,plen);
|
||||
|
||||
ethernet_header *eh = (ethernet_header *)icmp_packet;
|
||||
|
||||
eh->dst=eth->src;
|
||||
eh->src=gateway_mac;
|
||||
|
||||
ip_header *iph = (ip_header*)(eh+1);
|
||||
|
||||
iph->dst = ip->src;
|
||||
iph->src = virtual_gway_ip;
|
||||
|
||||
iph->hdr_csum = 0;
|
||||
|
||||
int sum = ip_checksum((u16*)iph,sizeof(ip_header));
|
||||
iph->hdr_csum = sum;
|
||||
|
||||
icmp_header *ich = (icmp_header*)(iph+1);
|
||||
|
||||
ich->type=0;
|
||||
ich->code=0;
|
||||
ich->csum=0;
|
||||
|
||||
sum = ip_checksum((u16*)ich,iph->len-sizeof(ip_header));
|
||||
ich->csum = sum;
|
||||
|
||||
recv_queue.push(packet_info(plen,&icmp_packet));
|
||||
|
||||
}
|
||||
else if (ip->dst.bytes[0] != 192) //PING to external
|
||||
{
|
||||
static u8 icmp_packet[1024];
|
||||
|
||||
memcpy(icmp_packet,packet,plen);
|
||||
|
||||
ethernet_header *eh = (ethernet_header *)icmp_packet;
|
||||
|
||||
eh->dst=eth->src;
|
||||
eh->src=gateway_mac;
|
||||
|
||||
ip_header *iph = (ip_header*)(eh+1);
|
||||
|
||||
iph->dst = ip->src;
|
||||
iph->src = virtual_gway_ip;
|
||||
|
||||
iph->hdr_csum = 0;
|
||||
|
||||
int sum = ip_checksum((u16*)iph,sizeof(ip_header));
|
||||
iph->hdr_csum = sum;
|
||||
|
||||
icmp_header *ich = (icmp_header*)(iph+1);
|
||||
|
||||
ich->type=0;
|
||||
ich->code=0;
|
||||
ich->csum=0;
|
||||
|
||||
sum = ip_checksum((u16*)ich,iph->len-sizeof(ip_header));
|
||||
ich->csum = sum;
|
||||
|
||||
recv_queue.push(packet_info(plen,&icmp_packet));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_io_recv(void* packet, int max_len)
|
||||
{
|
||||
if(pcap_io_running<=0)
|
||||
return -1;
|
||||
|
||||
if(!recv_queue.empty())
|
||||
{
|
||||
packet_info pkt(recv_queue.front());
|
||||
recv_queue.pop();
|
||||
|
||||
memcpy(packet,pkt.data,pkt.length);
|
||||
|
||||
if(packet_log)
|
||||
{
|
||||
int i=0;
|
||||
int n=0;
|
||||
int plen=pkt.length;
|
||||
|
||||
fprintf(packet_log,"PACKET RECV: %d BYTES\n",plen);
|
||||
for(i=0,n=0;i<plen;i++)
|
||||
{
|
||||
fprintf(packet_log,"%02x",((unsigned char*)packet)[i]);
|
||||
n++;
|
||||
if(n==16)
|
||||
{
|
||||
fprintf(packet_log,"\n");
|
||||
n=0;
|
||||
}
|
||||
else
|
||||
fprintf(packet_log," ");
|
||||
}
|
||||
fprintf(packet_log,"\n");
|
||||
}
|
||||
|
||||
return pkt.length;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void pcap_io_close()
|
||||
{
|
||||
if(packet_log)
|
||||
fclose(packet_log);
|
||||
pcap_io_running=0;
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
int pcap_io_get_dev_num()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
char* pcap_io_get_dev_name(int num)
|
||||
{
|
||||
return "SockIO";
|
||||
}
|
||||
|
||||
char* pcap_io_get_dev_desc(int num)
|
||||
{
|
||||
return "Simulated Ethernet Adapter";
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "net.h"
|
||||
#include "..\net.h"
|
||||
using namespace std;
|
||||
|
||||
struct tap_adapter
|
||||
|
@ -37,4 +37,4 @@ public:
|
|||
//sends the packet and deletes it when done (if successful).rv :true success
|
||||
virtual bool send(NetPacket* pkt);
|
||||
virtual ~TAPAdapter();
|
||||
};
|
||||
};
|
||||
|
|
|
@ -14,15 +14,17 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dev9.h"
|
||||
#include "DEV9.h"
|
||||
|
||||
void ata_init();
|
||||
void ata_term();
|
||||
|
||||
template<int sz>
|
||||
void CALLBACK ata_write(u32 addr, u32 value);
|
||||
void ata_write(u32 addr, u32 value);
|
||||
template<int sz>
|
||||
u8 CALLBACK ata_read(u32 addr);
|
||||
u8 ata_read(u32 addr);
|
||||
|
||||
void CALLBACK ata_readDMA8Mem(u32 *pMem, int size);
|
||||
void CALLBACK ata_writeDMA8Mem(u32 *pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
ata_readDMA8Mem(u32 *pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
ata_writeDMA8Mem(u32 *pMem, int size);
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
// The code has been designed for 64Mb flash and uses as file support the second memory card
|
||||
#include <stdio.h>
|
||||
#include <winsock2.h>
|
||||
//#include <winsock2.h>
|
||||
#include "DEV9.h"
|
||||
|
||||
#define PAGE_SIZE_BITS 9
|
||||
|
@ -31,7 +31,7 @@
|
|||
static volatile u32 ctrl, cmd= (u32)-1, address, id, counter, addrbyte;
|
||||
static u8 data[PAGE_SIZE_ECC], file[CARD_SIZE_ECC];
|
||||
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char xor[4]);
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char blah[4]);
|
||||
|
||||
static void calculateECC(u8 page[PAGE_SIZE_ECC]){
|
||||
memset(page+PAGE_SIZE, 0x00, ECC_SIZE);
|
||||
|
@ -41,7 +41,7 @@ static void calculateECC(u8 page[PAGE_SIZE_ECC]){
|
|||
xfromman_call20_calculateXors(page + 3*(PAGE_SIZE>>2), page+PAGE_SIZE+3*3);//(ECC_SIZE>>2));
|
||||
}
|
||||
|
||||
static char* getCmdName(u32 cmd){
|
||||
static const char* getCmdName(u32 cmd){
|
||||
switch(cmd) {
|
||||
case SM_CMD_READ1: return "READ1";
|
||||
case SM_CMD_READ2: return "READ2";
|
||||
|
@ -57,7 +57,8 @@ static char* getCmdName(u32 cmd){
|
|||
}
|
||||
}
|
||||
|
||||
void CALLBACK FLASHinit(){
|
||||
EXPORT_C_(void)
|
||||
FLASHinit(){
|
||||
FILE *fd;
|
||||
|
||||
id= FLASH_ID_64MBIT;
|
||||
|
@ -69,14 +70,20 @@ void CALLBACK FLASHinit(){
|
|||
calculateECC(data);
|
||||
ctrl = FLASH_PP_READY;
|
||||
|
||||
if (fd=fopen("flash.dat", "rb")){
|
||||
fread(file, 1, CARD_SIZE_ECC, fd);
|
||||
fd=fopen("flash.dat", "rb");
|
||||
if (fd != NULL){
|
||||
size_t ret;
|
||||
|
||||
ret = fread(file, 1, CARD_SIZE_ECC, fd);
|
||||
if (ret != CARD_SIZE_ECC) { DEV9_LOG("Reading error."); }
|
||||
|
||||
fclose(fd);
|
||||
}else
|
||||
memset(file, 0xFF, CARD_SIZE_ECC);
|
||||
}
|
||||
|
||||
u32 CALLBACK FLASHread32(u32 addr, int size) {
|
||||
EXPORT_C_(u32)
|
||||
FLASHread32(u32 addr, int size) {
|
||||
u32 value, refill= 0;
|
||||
|
||||
switch(addr) {
|
||||
|
@ -133,14 +140,16 @@ u32 CALLBACK FLASHread32(u32 addr, int size) {
|
|||
DEV9_LOG("*FLASH STATUS %dbit read 0x%08lX\n", size*8, value);
|
||||
return value;
|
||||
}//else fall off
|
||||
return 0;
|
||||
|
||||
default:
|
||||
DEV9_LOG("*FLASH Unkwnown %dbit read at address %lx\n", size*8, addr);
|
||||
DEV9_LOG("*FLASH Unknown %dbit read at address %lx\n", size*8, addr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CALLBACK FLASHwrite32(u32 addr, u32 value, int size) {
|
||||
EXPORT_C_(void)
|
||||
FLASHwrite32(u32 addr, u32 value, int size) {
|
||||
|
||||
switch(addr & 0x1FFFFFFF) {
|
||||
case FLASH_R_DATA:
|
||||
|
@ -247,7 +256,7 @@ static unsigned char xor_table[256]={
|
|||
0xC3, 0x44, 0x55, 0xD2, 0x66, 0xE1, 0xF0, 0x77, 0x77, 0xF0, 0xE1, 0x66, 0xD2, 0x55, 0x44, 0xC3,
|
||||
0x00, 0x87, 0x96, 0x11, 0xA5, 0x22, 0x33, 0xB4, 0xB4, 0x33, 0x22, 0xA5, 0x11, 0x96, 0x87, 0x00};
|
||||
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char xor[4]){
|
||||
static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned char blah[4]){
|
||||
register unsigned char a=0, b=0, c=0, i;
|
||||
|
||||
for (i=0; i<128; i++){
|
||||
|
@ -258,7 +267,7 @@ static void xfromman_call20_calculateXors(unsigned char buffer[128], unsigned ch
|
|||
}
|
||||
}
|
||||
|
||||
xor[0]=(~a) & 0x77;
|
||||
xor[1]=(~b) & 0x7F;
|
||||
xor[2]=(~c) & 0x7F;
|
||||
blah[0]=(~a) & 0x77;
|
||||
blah[1]=(~b) & 0x7F;
|
||||
blah[2]=(~c) & 0x7F;
|
||||
}
|
||||
|
|
|
@ -18,23 +18,22 @@
|
|||
#include "pcap.h"
|
||||
#include "pcap_io.h"
|
||||
|
||||
#include "dev9.h"
|
||||
#include "DEV9.h"
|
||||
#include "net.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Iphlpapi.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
enum pcap_m_e
|
||||
{
|
||||
switched,
|
||||
bridged
|
||||
};
|
||||
pcap_m_e pcap_mode=switched;
|
||||
mac_address virtual_mac = { 0x76, 0x6D, 0x61, 0x63, 0x30, 0x31 };
|
||||
//mac_address virtual_mac = { 0x6D, 0x76, 0x63, 0x61, 0x31, 0x30 };
|
||||
#ifndef PCAP_NETMASK_UNKNOWN
|
||||
#define PCAP_NETMASK_UNKNOWN 0xffffffff
|
||||
#endif
|
||||
|
||||
mac_address virtual_mac = { 0x00,0x24,0x8D,0x63, 0x30, 0x31 }; // first three recognized by Xlink as Sony PS2
|
||||
mac_address broadcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
mac_address gateway_mac = { 0x76, 0x6D, 0x61, 0x63, 0x31, 0x32 };
|
||||
|
||||
ip_address virtual_ip = { 192, 168, 1, 4};
|
||||
|
||||
pcap_t *adhandle;
|
||||
int pcap_io_running=0;
|
||||
|
@ -43,8 +42,6 @@ char errbuf[PCAP_ERRBUF_SIZE];
|
|||
|
||||
char namebuff[256];
|
||||
|
||||
FILE*packet_log;
|
||||
|
||||
pcap_dumper_t *dump_pcap;
|
||||
|
||||
mac_address host_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
@ -52,6 +49,8 @@ mac_address host_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|||
// Fetches the MAC address and prints it
|
||||
int GetMACAddress(char *adapter, mac_address* addr)
|
||||
{
|
||||
int retval = 0;
|
||||
#ifdef _WIN32
|
||||
static IP_ADAPTER_INFO AdapterInfo[128]; // Allocate information
|
||||
// for up to 128 NICs
|
||||
static PIP_ADAPTER_INFO pAdapterInfo;
|
||||
|
@ -66,7 +65,7 @@ int GetMACAddress(char *adapter, mac_address* addr)
|
|||
pAdapterInfo = AdapterInfo; // Contains pointer to
|
||||
// current adapter info
|
||||
do {
|
||||
if(strcmp(pAdapterInfo->AdapterName,adapter+12)==0)
|
||||
if(strcmp(pAdapterInfo->AdapterName,adapter)==0)
|
||||
{
|
||||
memcpy(addr,pAdapterInfo->Address,6);
|
||||
return 1;
|
||||
|
@ -75,53 +74,75 @@ int GetMACAddress(char *adapter, mac_address* addr)
|
|||
pAdapterInfo = pAdapterInfo->Next; // Progress through
|
||||
}
|
||||
while(pAdapterInfo); // Terminate if last adapter
|
||||
return 0;
|
||||
#elif defined(__linux__)
|
||||
struct ifreq ifr;
|
||||
int fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
strcpy(ifr.ifr_name, adapter);
|
||||
if (0 == ioctl(fd, SIOCGIFHWADDR, &ifr))
|
||||
{
|
||||
retval = 1;
|
||||
memcpy(addr,ifr.ifr_hwaddr.sa_data,6);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMessage("Could not get MAC address for adapter: %s", adapter);
|
||||
}
|
||||
close(fd);
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
int pcap_io_init(char *adapter)
|
||||
{
|
||||
struct bpf_program fp;
|
||||
char filter[1024] = "ether broadcast or ether dst ";
|
||||
int dlt;
|
||||
char *dlt_name;
|
||||
emu_printf("Opening adapter '%s'...",adapter);
|
||||
u16 checksum;
|
||||
GetMACAddress(adapter,&host_mac);
|
||||
|
||||
//Near copy of the host mac, butchered slightly, should be pretty good!
|
||||
eeprom[0] = host_mac.bytes[0];
|
||||
eeprom[1] = host_mac.bytes[1];
|
||||
eeprom[2] = host_mac.bytes[2];
|
||||
eeprom[3] = host_mac.bytes[2];
|
||||
eeprom[4] = host_mac.bytes[5];
|
||||
eeprom[5] = host_mac.bytes[4];
|
||||
//Lets take the hosts last 2 bytes to make it unique on Xlink
|
||||
virtual_mac.bytes[4] = host_mac.bytes[4];
|
||||
virtual_mac.bytes[5] = host_mac.bytes[5];
|
||||
|
||||
for(int ii=0; ii<6; ii++)
|
||||
eeprom[ii] = virtual_mac.bytes[ii];
|
||||
|
||||
virtual_mac.bytes[0] = host_mac.bytes[0];
|
||||
virtual_mac.bytes[1] = host_mac.bytes[1];
|
||||
virtual_mac.bytes[2] = host_mac.bytes[2];
|
||||
virtual_mac.bytes[3] = host_mac.bytes[2];
|
||||
virtual_mac.bytes[4] = host_mac.bytes[5];
|
||||
virtual_mac.bytes[5] = host_mac.bytes[4];
|
||||
//The checksum seems to be all the values of the mac added up in 16bit chunks
|
||||
checksum = dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2] & 0xffff;
|
||||
checksum = (dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2]) & 0xffff;
|
||||
|
||||
dev9.eeprom[3] = checksum;
|
||||
|
||||
//emu_printf("eeprom Mac set to %x %x %x %x %x %x", eeprom[0], eeprom[1], eeprom[2], eeprom[3], eeprom[4], eeprom[5]);
|
||||
//emu_printf("Checksum %x %x", eeprom[6], eeprom[7]);
|
||||
|
||||
/* Open the adapter */
|
||||
if ((adhandle= pcap_open_live(adapter, // name of the device
|
||||
65536, // portion of the packet to capture.
|
||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||
pcap_mode==switched?1:0, // promiscuous mode (nonzero means promiscuous)
|
||||
1, // promiscuous for Xlink usage
|
||||
1, // read timeout
|
||||
errbuf // error buffer
|
||||
)) == NULL)
|
||||
{
|
||||
fprintf(stderr, errbuf);
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", adapter);
|
||||
fprintf(stderr, "%s", errbuf);
|
||||
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by pcap\n", adapter);
|
||||
return -1;
|
||||
}
|
||||
char virtual_mac_str[18];
|
||||
sprintf(virtual_mac_str, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" , virtual_mac.bytes[0], virtual_mac.bytes[1], virtual_mac.bytes[2], virtual_mac.bytes[3], virtual_mac.bytes[4], virtual_mac.bytes[5]);
|
||||
strcat(filter,virtual_mac_str);
|
||||
// fprintf(stderr, "Trying pcap filter: %s\n", filter);
|
||||
|
||||
if(pcap_compile(adhandle,&fp,filter,1,PCAP_NETMASK_UNKNOWN) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error calling pcap_compile: %s\n", pcap_geterr(adhandle));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(pcap_setfilter(adhandle,&fp) == -1)
|
||||
{
|
||||
fprintf(stderr,"Error setting filter: %s\n", pcap_geterr(adhandle));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
dlt = pcap_datalink(adhandle);
|
||||
|
@ -139,16 +160,6 @@ int pcap_io_init(char *adapter)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(pcap_setnonblock(adhandle,1,errbuf)==-1)
|
||||
{
|
||||
fprintf(stderr,"WARNING: Error setting non-blocking mode. Default mode will be used.\n");
|
||||
}
|
||||
|
||||
//Changing the LogSetting might not affect logging
|
||||
//directory of winPcap logs if done after Open()
|
||||
const std::string pfile(s_strLogPath + "/packet.log");
|
||||
packet_log = fopen(pfile.c_str(), "w");
|
||||
|
||||
const std::string plfile(s_strLogPath + "/pkt_log.pcap");
|
||||
dump_pcap = pcap_dump_open(adhandle, plfile.c_str());
|
||||
|
||||
|
@ -157,6 +168,7 @@ int pcap_io_init(char *adapter)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int gettimeofday (struct timeval *tv, void* tz)
|
||||
{
|
||||
unsigned __int64 ns100; /*time since 1 Jan 1601 in 100ns units */
|
||||
|
@ -166,157 +178,40 @@ int gettimeofday (struct timeval *tv, void* tz)
|
|||
tv->tv_sec = (long) ((ns100 - 116444736000000000L) / 10000000L);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int pcap_io_send(void* packet, int plen)
|
||||
{
|
||||
struct pcap_pkthdr ph;
|
||||
|
||||
if(pcap_io_running<=0)
|
||||
return -1;
|
||||
emu_printf(" * pcap io: Sending %d byte packet.\n",plen);
|
||||
|
||||
if (pcap_mode==bridged)
|
||||
{
|
||||
if(((ethernet_header*)packet)->protocol == 0x0008) //IP
|
||||
{
|
||||
#ifndef PLOT_VERSION
|
||||
virtual_ip = ((ip_header*)((u8*)packet+sizeof(ethernet_header)))->src;
|
||||
#endif
|
||||
virtual_mac = ((ethernet_header*)packet)->src;
|
||||
}
|
||||
if(((ethernet_header*)packet)->protocol == 0x0608) //ARP
|
||||
{
|
||||
#ifndef PLOT_VERSION
|
||||
virtual_ip = ((arp_packet*)((u8*)packet+sizeof(ethernet_header)))->p_src;
|
||||
#endif
|
||||
virtual_mac = ((ethernet_header*)packet)->src;
|
||||
|
||||
((arp_packet*)((u8*)packet+sizeof(ethernet_header)))->h_src = host_mac;
|
||||
}
|
||||
((ethernet_header*)packet)->src = host_mac;
|
||||
}
|
||||
|
||||
if(dump_pcap)
|
||||
{
|
||||
static struct pcap_pkthdr ph;
|
||||
gettimeofday(&ph.ts,NULL);
|
||||
ph.caplen=plen;
|
||||
ph.len=plen;
|
||||
pcap_dump((u_char*)dump_pcap,&ph,(u_char*)packet);
|
||||
}
|
||||
|
||||
if(packet_log)
|
||||
{
|
||||
int i=0;
|
||||
int n=0;
|
||||
|
||||
fprintf(packet_log,"PACKET SEND: %d BYTES\n",plen);
|
||||
for(i=0,n=0;i<plen;i++)
|
||||
{
|
||||
fprintf(packet_log,"%02x",((unsigned char*)packet)[i]);
|
||||
n++;
|
||||
if(n==16)
|
||||
{
|
||||
fprintf(packet_log,"\n");
|
||||
n=0;
|
||||
}
|
||||
else
|
||||
fprintf(packet_log," ");
|
||||
}
|
||||
fprintf(packet_log,"\n");
|
||||
}
|
||||
|
||||
if (pcap_mode==switched)
|
||||
{
|
||||
if(mac_compare(((ethernet_header*)packet)->dst,broadcast_mac)==0)
|
||||
{
|
||||
static char pack[65536];
|
||||
memcpy(pack,packet,plen);
|
||||
|
||||
((ethernet_header*)packet)->dst=host_mac;
|
||||
pcap_sendpacket(adhandle, (u_char*)pack, plen);
|
||||
}
|
||||
}
|
||||
|
||||
return pcap_sendpacket(adhandle, (u_char*)packet, plen);
|
||||
}
|
||||
|
||||
int pcap_io_recv(void* packet, int max_len)
|
||||
{
|
||||
int res;
|
||||
struct pcap_pkthdr *header;
|
||||
const u_char *pkt_data1;
|
||||
static u_char pkt_data[32768];
|
||||
static struct pcap_pkthdr *header;
|
||||
static const u_char *pkt_data1;
|
||||
|
||||
if(pcap_io_running<=0)
|
||||
return -1;
|
||||
|
||||
if((res = pcap_next_ex(adhandle, &header, &pkt_data1)) > 0)
|
||||
if((pcap_next_ex(adhandle, &header, &pkt_data1)) > 0)
|
||||
{
|
||||
ethernet_header *ph=(ethernet_header*)pkt_data;
|
||||
|
||||
memcpy(pkt_data,pkt_data1,header->len);
|
||||
|
||||
if (pcap_mode==bridged)
|
||||
{
|
||||
if(((ethernet_header*)pkt_data)->protocol == 0x0008)
|
||||
{
|
||||
ip_header *iph=((ip_header*)((u8*)pkt_data+sizeof(ethernet_header)));
|
||||
if(ip_compare(iph->dst,virtual_ip)==0)
|
||||
{
|
||||
((ethernet_header*)pkt_data)->dst = virtual_mac;
|
||||
}
|
||||
}
|
||||
if(((ethernet_header*)pkt_data)->protocol == 0x0608)
|
||||
{
|
||||
arp_packet *aph=((arp_packet*)((u8*)pkt_data+sizeof(ethernet_header)));
|
||||
if(ip_compare(aph->p_dst,virtual_ip)==0)
|
||||
{
|
||||
((ethernet_header*)pkt_data)->dst = virtual_mac;
|
||||
((arp_packet*)((u8*)packet+sizeof(ethernet_header)))->h_dst = virtual_mac;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((memcmp(pkt_data,dev9.eeprom,6)!=0)&&(memcmp(pkt_data,&broadcast_mac,6)!=0))
|
||||
{
|
||||
//ignore strange packets
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(memcmp(pkt_data+6,dev9.eeprom,6)==0)
|
||||
{
|
||||
//avoid pcap looping packets
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(packet,pkt_data,header->len);
|
||||
memcpy(packet,pkt_data1,header->len);
|
||||
|
||||
if(dump_pcap)
|
||||
pcap_dump((u_char*)dump_pcap,header,(u_char*)packet);
|
||||
|
||||
|
||||
if(packet_log)
|
||||
{
|
||||
int i=0;
|
||||
int n=0;
|
||||
int plen=header->len;
|
||||
|
||||
fprintf(packet_log,"PACKET RECV: %d BYTES\n",plen);
|
||||
for(i=0,n=0;i<plen;i++)
|
||||
{
|
||||
fprintf(packet_log,"%02x",((unsigned char*)packet)[i]);
|
||||
n++;
|
||||
if(n==16)
|
||||
{
|
||||
fprintf(packet_log,"\n");
|
||||
n=0;
|
||||
}
|
||||
else
|
||||
fprintf(packet_log," ");
|
||||
}
|
||||
fprintf(packet_log,"\n");
|
||||
}
|
||||
|
||||
return header->len;
|
||||
}
|
||||
|
||||
|
@ -325,8 +220,6 @@ int pcap_io_recv(void* packet, int max_len)
|
|||
|
||||
void pcap_io_close()
|
||||
{
|
||||
if(packet_log)
|
||||
fclose(packet_log);
|
||||
if(dump_pcap)
|
||||
pcap_dump_close(dump_pcap);
|
||||
if (adhandle)
|
||||
|
@ -354,7 +247,7 @@ int pcap_io_get_dev_num()
|
|||
return i;
|
||||
}
|
||||
|
||||
char* pcap_io_get_dev_name(int num,int md)
|
||||
char* pcap_io_get_dev_name(int num)
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
|
@ -369,11 +262,7 @@ char* pcap_io_get_dev_name(int num,int md)
|
|||
while(d!=NULL) {
|
||||
if(num==i)
|
||||
{
|
||||
if (!md)
|
||||
strcpy(namebuff,"pcap switch:");
|
||||
else
|
||||
strcpy(namebuff,"pcap bridge:");
|
||||
strcat(namebuff,d->name);
|
||||
strcpy(namebuff,d->name);
|
||||
pcap_freealldevs(alldevs);
|
||||
return namebuff;
|
||||
}
|
||||
|
@ -385,7 +274,7 @@ char* pcap_io_get_dev_name(int num,int md)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char* pcap_io_get_dev_desc(int num,int md)
|
||||
char* pcap_io_get_dev_desc(int num)
|
||||
{
|
||||
pcap_if_t *alldevs;
|
||||
pcap_if_t *d;
|
||||
|
@ -400,11 +289,7 @@ char* pcap_io_get_dev_desc(int num,int md)
|
|||
while(d!=NULL) {
|
||||
if(num==i)
|
||||
{
|
||||
if (!md)
|
||||
strcpy(namebuff,"pcap switch:");
|
||||
else
|
||||
strcpy(namebuff,"pcap bridge:");
|
||||
strcat(namebuff,d->description);
|
||||
strcpy(namebuff,d->description);
|
||||
pcap_freealldevs(alldevs);
|
||||
return namebuff;
|
||||
}
|
||||
|
@ -420,12 +305,7 @@ char* pcap_io_get_dev_desc(int num,int md)
|
|||
PCAPAdapter::PCAPAdapter()
|
||||
{
|
||||
//if (config.ethEnable == 0) return; //whut? nada!
|
||||
if (config.Eth[5]=='s')
|
||||
pcap_mode=switched;
|
||||
else
|
||||
pcap_mode=bridged;
|
||||
|
||||
if (pcap_io_init(config.Eth+12) == -1) {
|
||||
if (pcap_io_init(config.Eth) == -1) {
|
||||
SysMessage("Can't open Device '%s'\n", config.Eth);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,8 +143,6 @@ typedef struct _full_arp_packet
|
|||
|
||||
extern mac_address virtual_mac;
|
||||
extern mac_address broadcast_mac;
|
||||
extern mac_address gateway_mac;
|
||||
extern ip_address virtual_ip;
|
||||
|
||||
#define mac_compare(a,b) (memcmp(&(a),&(b),6))
|
||||
#define ip_compare(a,b) (memcmp(&(a),&(b),4))
|
||||
|
@ -156,8 +154,8 @@ int pcap_io_recv(void* packet, int max_len);
|
|||
void pcap_io_close();
|
||||
*/
|
||||
int pcap_io_get_dev_num();
|
||||
char* pcap_io_get_dev_desc(int num,int md);
|
||||
char* pcap_io_get_dev_name(int num,int md);
|
||||
char* pcap_io_get_dev_desc(int num);
|
||||
char* pcap_io_get_dev_name(int num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -174,4 +172,4 @@ public:
|
|||
//sends the packet and deletes it when done (if successful).rv :true success
|
||||
virtual bool send(NetPacket* pkt);
|
||||
virtual ~PCAPAdapter();
|
||||
};
|
||||
};
|
|
@ -15,13 +15,15 @@
|
|||
|
||||
#define WINVER 0x0600
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <Winioctl.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <Winioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include <mutex>
|
||||
|
||||
|
@ -29,7 +31,6 @@
|
|||
#include "net.h"
|
||||
#include "pcap.h"
|
||||
#include "pcap_io.h"
|
||||
#include "tap.h"
|
||||
|
||||
bool has_link=true;
|
||||
volatile bool fireIntR = false;
|
||||
|
@ -88,11 +89,6 @@ bool rx_fifo_can_rx()
|
|||
|
||||
void rx_process(NetPacket* pk)
|
||||
{
|
||||
if (!rx_fifo_can_rx())
|
||||
{
|
||||
emu_printf("ERROR : !rx_fifo_can_rx at rx_process\n");
|
||||
return;
|
||||
}
|
||||
smap_bd_t *pbd= ((smap_bd_t *)&dev9.dev9R[SMAP_BD_RX_BASE & 0xffff])+dev9.rxbdi;
|
||||
|
||||
int bytes=(pk->size+3)&(~3);
|
||||
|
@ -322,7 +318,8 @@ void emac3_write(u32 addr)
|
|||
}
|
||||
dev9Ru32(addr)=wswap(value);
|
||||
}
|
||||
u8 CALLBACK smap_read8(u32 addr)
|
||||
EXPORT_C_(u8)
|
||||
smap_read8(u32 addr)
|
||||
{
|
||||
switch(addr)
|
||||
{
|
||||
|
@ -344,7 +341,8 @@ u8 CALLBACK smap_read8(u32 addr)
|
|||
DEV9_LOG("SMAP : error , 8 bit read @ %X,v=%X\n",addr,dev9Ru8(addr));
|
||||
return dev9Ru8(addr);
|
||||
}
|
||||
u16 CALLBACK smap_read16(u32 addr)
|
||||
EXPORT_C_(u16)
|
||||
smap_read16(u32 addr)
|
||||
{
|
||||
if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE))
|
||||
{
|
||||
|
@ -497,7 +495,8 @@ u16 CALLBACK smap_read16(u32 addr)
|
|||
return dev9Ru16(addr);
|
||||
}
|
||||
}
|
||||
u32 CALLBACK smap_read32(u32 addr)
|
||||
EXPORT_C_(u32)
|
||||
smap_read32(u32 addr)
|
||||
{
|
||||
if (addr>=SMAP_EMAC3_REGBASE && addr<SMAP_EMAC3_REGEND)
|
||||
{
|
||||
|
@ -536,7 +535,8 @@ u32 CALLBACK smap_read32(u32 addr)
|
|||
return dev9Ru32(addr);
|
||||
}
|
||||
}
|
||||
void CALLBACK smap_write8(u32 addr, u8 value)
|
||||
EXPORT_C_(void)
|
||||
smap_write8(u32 addr, u8 value)
|
||||
{
|
||||
std::unique_lock<std::mutex> reset_lock(reset_mutex, std::defer_lock);
|
||||
std::unique_lock<std::mutex> counter_lock(frame_counter_mutex, std::defer_lock);
|
||||
|
@ -611,7 +611,8 @@ void CALLBACK smap_write8(u32 addr, u8 value)
|
|||
return;
|
||||
}
|
||||
}
|
||||
void CALLBACK smap_write16(u32 addr, u16 value)
|
||||
EXPORT_C_(void)
|
||||
smap_write16(u32 addr, u16 value)
|
||||
{
|
||||
if (addr >= SMAP_BD_TX_BASE && addr < (SMAP_BD_TX_BASE + SMAP_BD_SIZE)) {
|
||||
if(dev9.bd_swap)
|
||||
|
@ -643,7 +644,7 @@ void CALLBACK smap_write16(u32 addr, u16 value)
|
|||
}
|
||||
else if (addr >= SMAP_BD_RX_BASE && addr < (SMAP_BD_RX_BASE + SMAP_BD_SIZE))
|
||||
{
|
||||
int rx_index=(addr - SMAP_BD_RX_BASE)>>3;
|
||||
//int rx_index=(addr - SMAP_BD_RX_BASE)>>3;
|
||||
if(dev9.bd_swap)
|
||||
value = (value>>8)|(value<<8);
|
||||
dev9Ru16(addr) = value;
|
||||
|
@ -791,7 +792,8 @@ void CALLBACK smap_write16(u32 addr, u16 value)
|
|||
return;
|
||||
}
|
||||
}
|
||||
void CALLBACK smap_write32(u32 addr, u32 value)
|
||||
EXPORT_C_(void)
|
||||
smap_write32(u32 addr, u32 value)
|
||||
{
|
||||
if (addr>=SMAP_EMAC3_REGBASE && addr<SMAP_EMAC3_REGEND)
|
||||
{
|
||||
|
@ -815,7 +817,8 @@ void CALLBACK smap_write32(u32 addr, u32 value)
|
|||
return;
|
||||
}
|
||||
}
|
||||
void CALLBACK smap_readDMA8Mem(u32 *pMem, int size)
|
||||
EXPORT_C_(void)
|
||||
smap_readDMA8Mem(u32 *pMem, int size)
|
||||
{
|
||||
if(dev9Ru16(SMAP_R_RXFIFO_CTRL)&SMAP_RXFIFO_DMAEN)
|
||||
{
|
||||
|
@ -835,7 +838,8 @@ void CALLBACK smap_readDMA8Mem(u32 *pMem, int size)
|
|||
dev9Ru16(SMAP_R_RXFIFO_CTRL) &= ~SMAP_RXFIFO_DMAEN;
|
||||
}
|
||||
}
|
||||
void CALLBACK smap_writeDMA8Mem(u32* pMem, int size)
|
||||
EXPORT_C_(void)
|
||||
smap_writeDMA8Mem(u32* pMem, int size)
|
||||
{
|
||||
if(dev9Ru16(SMAP_R_TXFIFO_CTRL)&SMAP_TXFIFO_DMAEN)
|
||||
{
|
||||
|
@ -858,7 +862,8 @@ void CALLBACK smap_writeDMA8Mem(u32* pMem, int size)
|
|||
|
||||
}
|
||||
}
|
||||
void CALLBACK smap_async(u32 cycles)
|
||||
EXPORT_C_(void)
|
||||
smap_async(u32 cycles)
|
||||
{
|
||||
if (fireIntR)
|
||||
{
|
|
@ -14,16 +14,25 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "..\dev9.h"
|
||||
#include "DEV9.h"
|
||||
|
||||
u8 CALLBACK smap_read8(u32 addr);
|
||||
u16 CALLBACK smap_read16(u32 addr);
|
||||
u32 CALLBACK smap_read32(u32 addr);
|
||||
EXPORT_C_(u8)
|
||||
smap_read8(u32 addr);
|
||||
EXPORT_C_(u16)
|
||||
smap_read16(u32 addr);
|
||||
EXPORT_C_(u32)
|
||||
smap_read32(u32 addr);
|
||||
|
||||
void CALLBACK smap_write8(u32 addr, u8 value);
|
||||
void CALLBACK smap_write16(u32 addr, u16 value);
|
||||
void CALLBACK smap_write32(u32 addr, u32 value);
|
||||
EXPORT_C_(void)
|
||||
smap_write8(u32 addr, u8 value);
|
||||
EXPORT_C_(void)
|
||||
smap_write16(u32 addr, u16 value);
|
||||
EXPORT_C_(void)
|
||||
smap_write32(u32 addr, u32 value);
|
||||
|
||||
void CALLBACK smap_readDMA8Mem(u32 *pMem, int size);
|
||||
void CALLBACK smap_writeDMA8Mem(u32 *pMem, int size);
|
||||
void CALLBACK smap_async(u32 cycles);
|
||||
EXPORT_C_(void)
|
||||
smap_readDMA8Mem(u32 *pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
smap_writeDMA8Mem(u32 *pMem, int size);
|
||||
EXPORT_C_(void)
|
||||
smap_async(u32 cycles);
|
Loading…
Reference in New Issue