Skip to content

Commit

Permalink
rework handling of DIG architecture
Browse files Browse the repository at this point in the history
now both disassembler and mad architecture is in sync and it is control by one macro DIG<architecture>
  • Loading branch information
jmalak committed Oct 31, 2022
1 parent 078d74a commit 66044ea
Show file tree
Hide file tree
Showing 36 changed files with 446 additions and 338 deletions.
22 changes: 11 additions & 11 deletions bld/dig/digcli.mif
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ dig_objs_qnx386 = $(_subdir_)ldimp.obj
!endif
dig_objs = $(dig_objs_$(objs_subdir))

dig_arch_cpp_flags_i86 =-DMD_x86
dig_arch_cpp_flags_386 =-DMD_x86
dig_arch_cpp_flags_x86 =-DMD_x86
dig_arch_cpp_flags_x64 =-DMD_x64
dig_arch_cpp_flags_axp =-DMD_axp
dig_arch_cpp_flags_ppc =-DMD_ppc
dig_arch_cpp_flags_mps =-DMD_mps
dig_arch_cpp_flags_jvm =-DMD_jvm
dig_arch_cpp_flags_sparc =-DMD_sparc
dig_arch_cpp_flags_test =-DMD_test
dig_arch_cpp_flags_all =-DMD_all
dig_arch_cpp_flags_i86 =-DDIGX86
dig_arch_cpp_flags_386 =-DDIGX86
dig_arch_cpp_flags_x86 =-DDIGX86
dig_arch_cpp_flags_x64 =-DDIGX64
dig_arch_cpp_flags_axp =-DDIGAXP
dig_arch_cpp_flags_ppc =-DDIGPPC
dig_arch_cpp_flags_mps =-DDIGMIPS
dig_arch_cpp_flags_jvm =-DDIGJVM
dig_arch_cpp_flags_sparc =-DDIGSPARC
dig_arch_cpp_flags_test =-DDIGTEST
dig_arch_cpp_flags_all =-DDIGALL
!ifdef dig_arch_cpp_flags_$(dig_arch)
dig_arch_cpp_flags =$(dig_arch_cpp_flags_$(dig_arch))
!endif
63 changes: 63 additions & 0 deletions bld/dig/h/madconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/****************************************************************************
*
* Open Watcom Project
*
* Copyright (c) 2022-2022 The Open Watcom Contributors. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Target architecture related declarations (MAD).
*
****************************************************************************/


#ifndef MADCONF_H_INCLUDED
#define MADCONF_H_INCLUDED

#define MADARCH_NONE 0x00
#define MADARCH_AXP 0x01
#define MADARCH_PPC 0x02
#define MADARCH_X86 0x04
#define MADARCH_X64 0x08
#define MADARCH_MIPS 0x10
#define MADARCH_JVM 0x20

#if defined( DIGAXP )
#define MADARCH MADARCH_AXP
#elif defined( DIGPPC )
#define MADARCH MADARCH_PPC
#elif defined( DIGX86 )
#define MADARCH MADARCH_X86
#elif defined( DIGX64 )
#define MADARCH MADARCH_X64
#elif defined( DIGJVM )
#define MADARCH MADARCH_JVM
#elif defined( DIGMIPS )
#define MADARCH MADARCH_MIPS
#elif defined( DIGALL )
#define MADARCH (MADARCH_AXP | MADARCH_MIPS | MADARCH_PPC | MADARCH_X86 | MADARCH_X64)
#endif

#ifndef MADARCH
#error "MAD: undefined/missing/incorrect DIG Architecture"
#endif

#endif
64 changes: 20 additions & 44 deletions bld/dig/h/madregs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,99 +33,75 @@
#ifndef MADREGS_H_INCLUDED
#define MADREGS_H_INCLUDED

#include "madconf.h"
#include "madtypes.h"

#undef MADREGSOK

#if defined( MD_all ) || defined( MD_test )
#define MD_x86
// #define MD_x64
#define MD_axp
#define MD_ppc
#define MD_mps
#if defined( MD_test )
#define MD_jvm
#endif
#endif

#if defined( MD_x86 )
#if MADARCH & (MADARCH_X86 | MADARCH_X64)
#include "madx86.h"
#define MADREGSOK
#endif

#if defined( MD_x64 )
#include "madx86.h"
#if MADARCH & MADARCH_X64
// #include "madx64.h"
#define MADREGSOK
#endif

#ifdef MD_axp
#if MADARCH & MADARCH_AXP
#include "madaxp.h"
#define MADREGSOK
#endif

#ifdef MD_ppc
#if MADARCH & MADARCH_PPC
#include "madppc.h"
#define MADREGSOK
#endif

#ifdef MD_mps
#if MADARCH & MADARCH_MIPS
#include "madmips.h"
#define MADREGSOK
#endif

#ifdef MD_jvm
#if MADARCH & MADARCH_JVM
#include "madjvm.h"
#define MADREGSOK
#endif

#ifndef MADREGSOK
#error "madregs.h undefined DIG Architecture"
#endif

#include "digpck.h"

union mad_registers {
unsigned_8 nul;
#ifdef MD_x86
#if MADARCH & (MADARCH_X86 | MADARCH_X64)
struct x86_mad_registers x86;
#endif
#ifdef MD_x64
struct x86_mad_registers x86;
#if MADARCH & MADARCH_X64
// struct x64_mad_registers x64;
#endif
#ifdef MD_axp
#if MADARCH & MADARCH_AXP
struct axp_mad_registers axp;
#endif
#ifdef MD_ppc
#if MADARCH & MADARCH_PPC
struct ppc_mad_registers ppc;
#endif
#ifdef MD_mps
#if MADARCH & MADARCH_MIPS
struct mips_mad_registers mips;
#endif
#ifdef MD_jvm
#if MADARCH & MADARCH_JVM
struct jvm_mad_registers jvm;
#endif
};

typedef union machine_data_spec {
unsigned_8 nul;
#ifdef MD_x86
#if MADARCH & (MADARCH_X86 | MADARCH_X64)
x86_addrflags x86_addr_flags;
#endif
#ifdef MD_x64
x64_addrflags x64_addr_flags;
#if MADARCH & MADARCH_X64
// x64_addrflags x64_addr_flags;
#endif
#ifdef MD_axp
#if MADARCH & MADARCH_AXP
axp_pdata_struct axp_pdata;
#endif
#ifdef MD_ppc
#if MADARCH & MADARCH_PPC
// ppc_pdata_struct ppc_pdata;
#endif
#ifdef MD_mps
#if MADARCH & MADARCH_MIPS
// mips_pdata_struct mips_pdata;
#endif
#ifdef MD_jvm
#if MADARCH & MADARCH_JVM
// jvm_pdata_struct jvm_pdata;
#endif
} machine_data_spec;
Expand Down
7 changes: 4 additions & 3 deletions bld/dig/h/madtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -32,13 +33,13 @@
#ifndef MADTYPES_H_INCLUDED
#define MADTYPES_H_INCLUDED

#include "madstr.h"
#include "digtypes.h"
#include "digpck.h"

#include "madstr.h"

#define SIGNTYPE_SIZE(x) (-(int)(x))

#include "digpck.h"

struct mad_reg_set_data;
struct mad_state_data;
struct mad_disasm_data;
Expand Down
3 changes: 2 additions & 1 deletion bld/mad/axp/c/axpdisas.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -39,7 +40,7 @@ static dis_handle DH;

mad_status DisasmInit()
{
if( DisInit( DISCPU_axp, &DH, false ) != DR_OK ) {
if( DisInit( DISCPU_AXP, &DH, false ) != DR_OK ) {
return( MS_ERR | MS_FAIL );
}
return( MS_OK );
Expand Down
3 changes: 2 additions & 1 deletion bld/mad/jvm/c/jvmdisas.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -41,7 +42,7 @@ static dis_handle DH;

mad_status DisasmInit()
{
if( DisInit( DISCPU_jvm, &DH ) != DR_OK ) {
if( DisInit( DISCPU_JVM, &DH ) != DR_OK ) {
return( MS_ERR | MS_FAIL );
}
return( MS_OK );
Expand Down
3 changes: 2 additions & 1 deletion bld/mad/mps/c/mpsdisas.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -46,7 +47,7 @@ mad_status DisasmInit()
#else
swap_bytes = false;
#endif
if( DisInit( DISCPU_mips, &DH, swap_bytes ) != DR_OK ) {
if( DisInit( DISCPU_MIPS, &DH, swap_bytes ) != DR_OK ) {
return( MS_ERR | MS_FAIL );
}
return( MS_OK );
Expand Down
3 changes: 2 additions & 1 deletion bld/mad/ppc/c/ppcdisas.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -46,7 +47,7 @@ mad_status DisasmInit()
#else
swap_bytes = true;
#endif
if( DisInit( DISCPU_ppc, &DH, swap_bytes ) != DR_OK ) {
if( DisInit( DISCPU_PPC, &DH, swap_bytes ) != DR_OK ) {
return( MS_ERR | MS_FAIL );
}
return( MS_OK );
Expand Down
2 changes: 1 addition & 1 deletion bld/mad/x86/c/x86disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ size_t DisCliValueString( void *d, dis_dec_ins *ins, unsigned opnd, char *buff,

mad_status DisasmInit( void )
{
if( DisInit( DISCPU_x86, &DH, false ) != DR_OK ) {
if( DisInit( DISCPU_X86, &DH, false ) != DR_OK ) {
return( MS_ERR | MS_FAIL );
}
return( MS_OK );
Expand Down
Loading

0 comments on commit 66044ea

Please sign in to comment.