xref: /freebsd/sys/amd64/include/gdb_machdep.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
146280ae7SWarner Losh /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3c49761ddSPedro F. Giffuni  *
472d44f31SMarcel Moolenaar  * Copyright (c) 2004 Marcel Moolenaar
572d44f31SMarcel Moolenaar  * All rights reserved.
672d44f31SMarcel Moolenaar  *
772d44f31SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
872d44f31SMarcel Moolenaar  * modification, are permitted provided that the following conditions
972d44f31SMarcel Moolenaar  * are met:
1072d44f31SMarcel Moolenaar  *
1172d44f31SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
1272d44f31SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
1372d44f31SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
1472d44f31SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
1572d44f31SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
1672d44f31SMarcel Moolenaar  *
1772d44f31SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1872d44f31SMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1972d44f31SMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2072d44f31SMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2172d44f31SMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2272d44f31SMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2372d44f31SMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2472d44f31SMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2572d44f31SMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2672d44f31SMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2772d44f31SMarcel Moolenaar  */
2872d44f31SMarcel Moolenaar 
2972d44f31SMarcel Moolenaar #ifndef _MACHINE_GDB_MACHDEP_H_
3072d44f31SMarcel Moolenaar #define	_MACHINE_GDB_MACHDEP_H_
3172d44f31SMarcel Moolenaar 
3279917681SConrad Meyer #define	GDB_BUFSZ	4096
3372d44f31SMarcel Moolenaar #define	GDB_NREGS	56
340ef474deSMitchell Horne #define	GDB_REG_RAX	0
350ef474deSMitchell Horne #define	GDB_REG_RBX	1
360ef474deSMitchell Horne #define	GDB_REG_RCX	2
370ef474deSMitchell Horne #define	GDB_REG_RDX	3
380ef474deSMitchell Horne #define	GDB_REG_RSI	4
390ef474deSMitchell Horne #define	GDB_REG_RDI	5
400ef474deSMitchell Horne #define	GDB_REG_RBP	6
410ef474deSMitchell Horne #define	GDB_REG_RSP	7
420ef474deSMitchell Horne #define	GDB_REG_R8	8
430ef474deSMitchell Horne #define	GDB_REG_R9	9
440ef474deSMitchell Horne #define	GDB_REG_R10	10
450ef474deSMitchell Horne #define	GDB_REG_R11	11
460ef474deSMitchell Horne #define	GDB_REG_R12	12
470ef474deSMitchell Horne #define	GDB_REG_R13	13
480ef474deSMitchell Horne #define	GDB_REG_R14	14
490ef474deSMitchell Horne #define	GDB_REG_R15	15
50470d8317SMarcel Moolenaar #define	GDB_REG_PC	16
5172939459SMitchell Horne #define	GDB_REG_RFLAGS	17
5272939459SMitchell Horne #define	GDB_REG_CS	18
5372939459SMitchell Horne #define	GDB_REG_SS	19
5479917681SConrad Meyer _Static_assert(GDB_BUFSZ >= (GDB_NREGS * 16), "buffer fits 'g' regs");
5572d44f31SMarcel Moolenaar 
5672d44f31SMarcel Moolenaar static __inline size_t
gdb_cpu_regsz(int regnum)5772d44f31SMarcel Moolenaar gdb_cpu_regsz(int regnum)
5872d44f31SMarcel Moolenaar {
5972d44f31SMarcel Moolenaar 	return ((regnum > 16 && regnum < 24) ? 4 : 8);
6072d44f31SMarcel Moolenaar }
6172d44f31SMarcel Moolenaar 
6272d44f31SMarcel Moolenaar static __inline int
gdb_cpu_query(void)6372d44f31SMarcel Moolenaar gdb_cpu_query(void)
6472d44f31SMarcel Moolenaar {
6572d44f31SMarcel Moolenaar 	return (0);
6672d44f31SMarcel Moolenaar }
6772d44f31SMarcel Moolenaar 
68beb24065SJonathan T. Looney void *gdb_begin_write(void);
6972d44f31SMarcel Moolenaar void *gdb_cpu_getreg(int, size_t *);
70bcc5241cSMarcel Moolenaar void gdb_cpu_setreg(int, void *);
71b1fb1bb1SMarcel Moolenaar int gdb_cpu_signal(int, int);
72beb24065SJonathan T. Looney void gdb_end_write(void *);
737446b088SMitchell Horne void gdb_cpu_stop_reason(int, int);
7472d44f31SMarcel Moolenaar 
7572d44f31SMarcel Moolenaar #endif /* !_MACHINE_GDB_MACHDEP_H_ */
76