17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 59acbbeafSnn * Common Development and Distribution License (the "License"). 69acbbeafSnn * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 229acbbeafSnn * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _FASTTRAP_ISA_H 277c478bd9Sstevel@tonic-gate #define _FASTTRAP_ISA_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #define FASTTRAP_MAX_INSTR_SIZE 15 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #define FASTTRAP_INSTR 0xcc 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define FASTTRAP_SUNWDTRACE_SIZE 64 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate typedef uint8_t fasttrap_instr_t; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate typedef struct fasttrap_machtp { 447c478bd9Sstevel@tonic-gate uint8_t ftmt_instr[FASTTRAP_MAX_INSTR_SIZE]; /* orig. instr. */ 457c478bd9Sstevel@tonic-gate uint8_t ftmt_size; /* instruction size */ 467c478bd9Sstevel@tonic-gate #ifdef __amd64 477c478bd9Sstevel@tonic-gate uint8_t ftmt_ripmode; /* %rip-relative handling mode */ 487c478bd9Sstevel@tonic-gate uint8_t ftmt_modrm; /* saved modrm byte */ 497c478bd9Sstevel@tonic-gate #endif 507c478bd9Sstevel@tonic-gate uint8_t ftmt_type; /* emulation type */ 517c478bd9Sstevel@tonic-gate uint8_t ftmt_code; /* branch condition */ 527c478bd9Sstevel@tonic-gate uint8_t ftmt_base; /* branch base */ 537c478bd9Sstevel@tonic-gate uint8_t ftmt_index; /* branch index */ 547c478bd9Sstevel@tonic-gate uint8_t ftmt_scale; /* branch scale */ 559acbbeafSnn uint8_t ftmt_segment; /* segment for memory accesses */ 567c478bd9Sstevel@tonic-gate uintptr_t ftmt_dest; /* destination of control flow */ 577c478bd9Sstevel@tonic-gate } fasttrap_machtp_t; 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #define ftt_instr ftt_mtp.ftmt_instr 607c478bd9Sstevel@tonic-gate #ifdef __amd64 617c478bd9Sstevel@tonic-gate #define ftt_ripmode ftt_mtp.ftmt_ripmode 627c478bd9Sstevel@tonic-gate #define ftt_modrm ftt_mtp.ftmt_modrm 637c478bd9Sstevel@tonic-gate #endif 647c478bd9Sstevel@tonic-gate #define ftt_size ftt_mtp.ftmt_size 657c478bd9Sstevel@tonic-gate #define ftt_type ftt_mtp.ftmt_type 667c478bd9Sstevel@tonic-gate #define ftt_code ftt_mtp.ftmt_code 677c478bd9Sstevel@tonic-gate #define ftt_base ftt_mtp.ftmt_base 687c478bd9Sstevel@tonic-gate #define ftt_index ftt_mtp.ftmt_index 697c478bd9Sstevel@tonic-gate #define ftt_scale ftt_mtp.ftmt_scale 709acbbeafSnn #define ftt_segment ftt_mtp.ftmt_segment 717c478bd9Sstevel@tonic-gate #define ftt_dest ftt_mtp.ftmt_dest 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define FASTTRAP_T_COMMON 0x00 /* common case -- no emulation */ 747c478bd9Sstevel@tonic-gate #define FASTTRAP_T_JCC 0x01 /* near and far conditional jumps */ 757c478bd9Sstevel@tonic-gate #define FASTTRAP_T_LOOP 0x02 /* loop instructions */ 767c478bd9Sstevel@tonic-gate #define FASTTRAP_T_JCXZ 0x03 /* jump if %ecx/%rcx is zero */ 777c478bd9Sstevel@tonic-gate #define FASTTRAP_T_JMP 0x04 /* relative jump */ 787c478bd9Sstevel@tonic-gate #define FASTTRAP_T_CALL 0x05 /* near call (and link) */ 797c478bd9Sstevel@tonic-gate #define FASTTRAP_T_RET 0x06 /* ret */ 807c478bd9Sstevel@tonic-gate #define FASTTRAP_T_RET16 0x07 /* ret <imm16> */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * For performance rather than correctness. 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate #define FASTTRAP_T_PUSHL_EBP 0x10 /* pushl %ebp (for function entry) */ 86*2b6e762cSahl #define FASTTRAP_T_NOP 0x11 /* nop */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define FASTTRAP_RIP_1 0x1 897c478bd9Sstevel@tonic-gate #define FASTTRAP_RIP_2 0x2 907c478bd9Sstevel@tonic-gate #define FASTTRAP_RIP_X 0x4 917c478bd9Sstevel@tonic-gate 929acbbeafSnn /* 939acbbeafSnn * Segment values. 949acbbeafSnn */ 959acbbeafSnn #define FASTTRAP_SEG_NONE 0 969acbbeafSnn #define FASTTRAP_SEG_CS 1 979acbbeafSnn #define FASTTRAP_SEG_DS 2 989acbbeafSnn #define FASTTRAP_SEG_ES 3 999acbbeafSnn #define FASTTRAP_SEG_FS 4 1009acbbeafSnn #define FASTTRAP_SEG_GS 5 1019acbbeafSnn #define FASTTRAP_SEG_SS 6 1029acbbeafSnn 1037c478bd9Sstevel@tonic-gate #define FASTTRAP_AFRAMES 3 1047c478bd9Sstevel@tonic-gate #define FASTTRAP_RETURN_AFRAMES 4 1057c478bd9Sstevel@tonic-gate #define FASTTRAP_ENTRY_AFRAMES 3 1067c478bd9Sstevel@tonic-gate #define FASTTRAP_OFFSET_AFRAMES 3 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1097c478bd9Sstevel@tonic-gate } 1107c478bd9Sstevel@tonic-gate #endif 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #endif /* _FASTTRAP_ISA_H */ 113