Annotation of kernel/kern/kdp_protocol.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /* Copyright (c) 1991 by NeXT Computer, Inc.
        !            26:  *
        !            27:  *     File:   services/kdp.h
        !            28:  *
        !            29:  *     Definition of remote debugger protocol.
        !            30:  *
        !            31:  * HISTORY
        !            32:  * 10-Nov-1997  Umesh Vaishampayan  ([email protected])
        !            33:  *     Changed the magic numbers for udp ports.
        !            34:  *
        !            35:  * 10 Nov 97   Herb Ruth [[email protected]]
        !            36:  *     Removed trailing comma from kdp_req_t enumeration.
        !            37:  *
        !            38:  * 27-Oct-91  Mike DeMoney ([email protected])
        !            39:  *     Created
        !            40:  *
        !            41:  */
        !            42: 
        !            43: #import        <mach/vm_prot.h>
        !            44: 
        !            45: /*
        !            46:  * Retransmit parameters
        !            47:  */
        !            48: #if    DDEBUG_DEBUG || DEBUG_DEBUG
        !            49: #define        KDP_REXMIT_SECS         20      // rexmit if no ack in 3 secs
        !            50: #else  /* DDEBUG_DEBUG || DEBUG_DEBUG */
        !            51: #define        KDP_REXMIT_SECS         3       // rexmit if no ack in 3 secs
        !            52: #endif /* DDEBUG_DEBUG || DEBUG_DEBUG */
        !            53: #define        KDP_REXMIT_TRIES        8       // xmit 8 times, then give up
        !            54: 
        !            55: /*
        !            56:  * (NMI) Attention Max Wait Time
        !            57:  * Remote will resume unless KDP requests is received within this
        !            58:  * many seconds after an attention (nmi) packet is sent.
        !            59:  */
        !            60: #define        KDP_MAX_ATTN_WAIT       30      // wait max of 30 seconds
        !            61: 
        !            62: /*
        !            63:  * Well-known UDP port, debugger side.
        !            64:  * FIXME: This is what the 68K guys use, but beats me how they chose it...
        !            65:  */
        !            66: #define        KDP_REMOTE_PORT         41139   // pick one and register it
        !            67: 
        !            68: /*
        !            69:  * UDP ports, KDB side. 5 port numbers are reserved for each port (request
        !            70:  * and exception). This allows multiple KDBs to run on one host.
        !            71:  */
        !            72: #define UDP_HOST_COMM_BASE     41140
        !            73: #define UDP_HOST_EXCEP_BASE    41145
        !            74: #define NUM_UDP_HOST_PORTS     5
        !            75: 
        !            76: /*
        !            77:  * Requests
        !            78:  */
        !            79: typedef enum {
        !            80:        /* connection oriented requests */
        !            81:        KDP_CONNECT,    KDP_DISCONNECT,
        !            82: 
        !            83:        /* obtaining client info */
        !            84:        KDP_HOSTINFO,   KDP_REGIONS,    KDP_MAXBYTES,
        !            85:        
        !            86:        /* memory access */
        !            87:        KDP_READMEM,    KDP_WRITEMEM,
        !            88:        
        !            89:        /* register access */
        !            90:        KDP_READREGS,   KDP_WRITEREGS,
        !            91:        
        !            92:        /* executable image info */
        !            93:        KDP_LOAD,       KDP_IMAGEPATH,
        !            94:        
        !            95:        /* execution control */
        !            96:        KDP_SUSPEND,    KDP_RESUMECPUS,
        !            97:        
        !            98:        /* exception and termination notification, NOT true requests */
        !            99:        KDP_EXCEPTION,  KDP_TERMINATION
        !           100: } kdp_req_t;
        !           101: 
        !           102: /*
        !           103:  * Common KDP packet header
        !           104:  */
        !           105: typedef struct {
        !           106:        kdp_req_t       request:7;      // request type
        !           107:        unsigned        is_reply:1;     // 0 => request, 1 => reply
        !           108:        unsigned        seq:8;          // sequence number within session
        !           109:        unsigned        len:16;         // length of entire pkt including hdr
        !           110:        unsigned        key;            // session key
        !           111: } kdp_hdr_t;
        !           112: 
        !           113: /*
        !           114:  * KDP errors
        !           115:  */
        !           116: typedef enum {
        !           117:        KDPERR_NO_ERROR = 0,
        !           118:        KDPERR_ALREADY_CONNECTED,
        !           119:        KDPERR_BAD_NBYTES,
        !           120:        KDPERR_BADFLAVOR,               // bad flavor in w/r regs
        !           121: } kdp_error_t;
        !           122: 
        !           123: /*
        !           124:  * KDP requests and reply packet formats
        !           125:  */
        !           126: 
        !           127: /*
        !           128:  * KDP_CONNECT
        !           129:  */
        !           130: typedef struct {                       // KDP_CONNECT request
        !           131:        kdp_hdr_t       hdr;
        !           132:        unsigned short  req_reply_port; // udp port which to send replies
        !           133:        unsigned short  exc_note_port;  // udp port which to send exc notes
        !           134:        char            greeting[0];    // "greetings", null-terminated
        !           135: } kdp_connect_req_t;
        !           136: 
        !           137: typedef struct {                       // KDP_CONNECT reply
        !           138:        kdp_hdr_t       hdr;
        !           139:        kdp_error_t     error;
        !           140: } kdp_connect_reply_t;
        !           141: 
        !           142: /*
        !           143:  * KDP_DISCONNECT
        !           144:  */
        !           145: typedef struct {                       // KDP_DISCONNECT request
        !           146:        kdp_hdr_t       hdr;
        !           147: } kdp_disconnect_req_t;
        !           148: 
        !           149: typedef struct {                       // KDP_DISCONNECT reply
        !           150:        kdp_hdr_t       hdr;
        !           151: } kdp_disconnect_reply_t;
        !           152: 
        !           153: /*
        !           154:  * KDP_HOSTINFO
        !           155:  */
        !           156: typedef struct {                       // KDP_HOSTINFO request
        !           157:        kdp_hdr_t       hdr;
        !           158: } kdp_hostinfo_req_t;
        !           159: 
        !           160: typedef struct {
        !           161:        unsigned        cpus_mask;      // bit is 1 if cpu present
        !           162:        int             cpu_type;
        !           163:        int             cpu_subtype;
        !           164: } kdp_hostinfo_t;
        !           165: 
        !           166: typedef struct {                       // KDP_HOSTINFO reply
        !           167:        kdp_hdr_t       hdr;
        !           168:        kdp_hostinfo_t  hostinfo;
        !           169: } kdp_hostinfo_reply_t;
        !           170: 
        !           171: /*
        !           172:  * KDP_REGIONS
        !           173:  */
        !           174: typedef struct {                       // KDP_REGIONS request
        !           175:        kdp_hdr_t       hdr;
        !           176: } kdp_regions_req_t;
        !           177: 
        !           178: #define        VM_PROT_VOLATILE        ((vm_prot_t) 0x08)      // not cacheable
        !           179: #define        VM_PROT_SPARSE          ((vm_prot_t) 0x10)      // sparse addr space
        !           180: 
        !           181: typedef struct {
        !           182:        void            *address;
        !           183:        unsigned        nbytes;
        !           184:        vm_prot_t       protection;
        !           185: } kdp_region_t;
        !           186: 
        !           187: typedef struct {                       // KDP_REGIONS reply
        !           188:        kdp_hdr_t       hdr;
        !           189:        unsigned        nregions;
        !           190:        kdp_region_t    regions[0];
        !           191: } kdp_regions_reply_t;
        !           192: 
        !           193: /*
        !           194:  * KDP_MAXBYTES
        !           195:  */
        !           196: typedef struct {                       // KDP_MAXBYTES request
        !           197:        kdp_hdr_t       hdr;
        !           198: } kdp_maxbytes_req_t;
        !           199: 
        !           200: typedef struct {                       // KDP_MAXBYTES reply
        !           201:        kdp_hdr_t       hdr;
        !           202:        unsigned        max_bytes;
        !           203: } kdp_maxbytes_reply_t;
        !           204: 
        !           205: /*
        !           206:  * KDP_READMEM
        !           207:  */
        !           208: typedef struct {                       // KDP_READMEM request
        !           209:        kdp_hdr_t       hdr;
        !           210:        void            *address;
        !           211:        unsigned        nbytes;
        !           212: } kdp_readmem_req_t;
        !           213: 
        !           214: typedef struct {                       // KDP_READMEM reply
        !           215:        kdp_hdr_t       hdr;
        !           216:        kdp_error_t     error;
        !           217:        char            data[0];
        !           218: } kdp_readmem_reply_t;
        !           219: 
        !           220: /*
        !           221:  * KDP_WRITEMEM
        !           222:  */
        !           223: typedef struct {                       // KDP_WRITEMEM request
        !           224:        kdp_hdr_t       hdr;
        !           225:        void            *address;
        !           226:        unsigned        nbytes;
        !           227:        char            data[0];
        !           228: } kdp_writemem_req_t;
        !           229: 
        !           230: typedef struct {                       // KDP_WRITEMEM reply
        !           231:        kdp_hdr_t       hdr;
        !           232:        kdp_error_t     error;
        !           233: } kdp_writemem_reply_t;
        !           234: 
        !           235: /*
        !           236:  * KDP_READREGS
        !           237:  */
        !           238: typedef struct {                       // KDP_READREGS request
        !           239:        kdp_hdr_t       hdr;
        !           240:        unsigned        cpu;
        !           241:        unsigned        flavor;
        !           242: } kdp_readregs_req_t;
        !           243: 
        !           244: typedef struct {                       // KDP_READREGS reply
        !           245:        kdp_hdr_t       hdr;
        !           246:        kdp_error_t     error;          // could be KDPERR_BADFLAVOR
        !           247:        char            data[0];
        !           248: } kdp_readregs_reply_t;
        !           249: 
        !           250: /*
        !           251:  * KDP_WRITEREGS
        !           252:  */
        !           253: typedef struct {                       // KDP_WRITEREGS request
        !           254:        kdp_hdr_t       hdr;
        !           255:        unsigned        cpu;
        !           256:        unsigned        flavor;
        !           257:        char            data[0];
        !           258: } kdp_writeregs_req_t;
        !           259: 
        !           260: typedef struct {                       // KDP_WRITEREGS reply
        !           261:        kdp_hdr_t       hdr;
        !           262:        kdp_error_t     error;
        !           263: } kdp_writeregs_reply_t;
        !           264: 
        !           265: /*
        !           266:  * KDP_LOAD
        !           267:  */
        !           268: typedef struct {                       // KDP_LOAD request
        !           269:        kdp_hdr_t       hdr;
        !           270:        char            file_args[0];
        !           271: } kdp_load_req_t;
        !           272: 
        !           273: typedef struct {                       // KDP_LOAD reply
        !           274:        kdp_hdr_t       hdr;
        !           275:        kdp_error_t     error;
        !           276: } kdp_load_reply_t;
        !           277: 
        !           278: /*
        !           279:  * KDP_IMAGEPATH
        !           280:  */
        !           281: typedef struct {                       // KDP_IMAGEPATH request
        !           282:        kdp_hdr_t       hdr;
        !           283: } kdp_imagepath_req_t;
        !           284: 
        !           285: typedef struct {                       // KDP_IMAGEPATH reply
        !           286:        kdp_hdr_t       hdr;
        !           287:        char            path[0];
        !           288: } kdp_imagepath_reply_t;
        !           289: 
        !           290: /*
        !           291:  * KDP_SUSPEND
        !           292:  */
        !           293: typedef struct {                       // KDP_SUSPEND request
        !           294:        kdp_hdr_t       hdr;
        !           295: } kdp_suspend_req_t;
        !           296: 
        !           297: typedef struct {                       // KDP_SUSPEND reply
        !           298:        kdp_hdr_t       hdr;
        !           299: } kdp_suspend_reply_t;
        !           300: 
        !           301: /*
        !           302:  * KDP_RESUMECPUS
        !           303:  */
        !           304: typedef struct {                       // KDP_RESUMECPUS request
        !           305:        kdp_hdr_t       hdr;
        !           306:        unsigned        cpu_mask;
        !           307: } kdp_resumecpus_req_t;
        !           308: 
        !           309: typedef struct {                       // KDP_RESUMECPUS reply
        !           310:        kdp_hdr_t       hdr;
        !           311: } kdp_resumecpus_reply_t;
        !           312: 
        !           313: /*
        !           314:  * Exception notifications
        !           315:  * (Exception notifications are not requests, and in fact travel from
        !           316:  * the remote debugger to the gdb agent KDB.)
        !           317:  */
        !           318: typedef struct {                       // exc. info for one cpu
        !           319:        unsigned        cpu;
        !           320:        /*
        !           321:         * Following info is defined as
        !           322:         * per <mach/exception.h>
        !           323:         */
        !           324:        unsigned        exception;
        !           325:        unsigned        code;
        !           326:        unsigned        subcode;
        !           327: } kdp_exc_info_t;
        !           328: 
        !           329: typedef struct {                       // KDP_EXCEPTION notification
        !           330:        kdp_hdr_t       hdr;
        !           331:        unsigned        n_exc_info;
        !           332:        kdp_exc_info_t  exc_info[0];
        !           333: } kdp_exception_t;
        !           334: 
        !           335: typedef struct {                       // KDP_EXCEPTION acknowledgement
        !           336:        kdp_hdr_t       hdr;
        !           337: } kdp_exception_ack_t;
        !           338: 
        !           339: /*
        !           340:  * Child termination messages
        !           341:  */
        !           342: typedef enum {
        !           343:        KDP_FAULT = 0,          // child took fault (internal use)
        !           344:        KDP_EXIT,               // child exited
        !           345:        KDP_POWEROFF,           // child power-off
        !           346:        KDP_REBOOT,             // child reboot
        !           347:        KDP_COMMAND_MODE,       // child exit to mon command_mode
        !           348: } kdp_termination_code_t;
        !           349: 
        !           350: typedef struct {                       // KDP_TERMINATION notification
        !           351:        kdp_hdr_t               hdr;
        !           352:        kdp_termination_code_t  term_code;
        !           353:        unsigned                exit_code;
        !           354: } kdp_termination_t;
        !           355: 
        !           356: typedef struct {
        !           357:        kdp_hdr_t       hdr;
        !           358: } kdp_termination_ack_t;
        !           359: 
        !           360: typedef union {
        !           361:        kdp_hdr_t               hdr;
        !           362:        kdp_connect_req_t       connect_req;
        !           363:        kdp_connect_reply_t     connect_reply;
        !           364:        kdp_disconnect_req_t    disconnect_req;
        !           365:        kdp_disconnect_reply_t  disconnect_reply;
        !           366:        kdp_hostinfo_req_t      hostinfo_req;
        !           367:        kdp_hostinfo_reply_t    hostinfo_reply;
        !           368:        kdp_regions_req_t       regions_req;
        !           369:        kdp_regions_reply_t     regions_reply;
        !           370:        kdp_maxbytes_req_t      maxbytes_req;
        !           371:        kdp_maxbytes_reply_t    maxbytes_reply;
        !           372:        kdp_readmem_req_t       readmem_req;
        !           373:        kdp_readmem_reply_t     readmem_reply;
        !           374:        kdp_writemem_req_t      writemem_req;
        !           375:        kdp_writemem_reply_t    writemem_reply;
        !           376:        kdp_readregs_req_t      readregs_req;
        !           377:        kdp_readregs_reply_t    readregs_reply;
        !           378:        kdp_writeregs_req_t     writeregs_req;
        !           379:        kdp_writeregs_reply_t   writeregs_reply;
        !           380:        kdp_load_req_t          load_req;
        !           381:        kdp_load_reply_t        load_reply;
        !           382:        kdp_imagepath_req_t     imagepath_req;
        !           383:        kdp_imagepath_reply_t   imagepath_reply;
        !           384:        kdp_suspend_req_t       suspend_req;
        !           385:        kdp_suspend_reply_t     suspend_reply;
        !           386:        kdp_resumecpus_req_t    resumecpus_req;
        !           387:        kdp_resumecpus_reply_t  resumecpus_reply;
        !           388:        kdp_exception_t         exception;
        !           389:        kdp_exception_ack_t     exception_ack;
        !           390:        kdp_termination_t       termination;
        !           391:        kdp_termination_ack_t   termination_ack;
        !           392: } kdp_pkt_t;
        !           393: 
        !           394: #define MAX_KDP_PKT_SIZE       1200    /* max packet size */
        !           395: #define MAX_KDP_DATA_SIZE      1024    /* max r/w data per packet */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.