1/* 2 * Copyright 2009 VMware, Inc. 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * on the rights to use, copy, modify, merge, publish, distribute, sub 9 * license, and/or sell copies of the Software, and to permit persons to whom 10 * the Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19 * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22 * USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25#include "rbug.h" 26 27/** 28 * Small function that looks at the proto_header and selects the correct 29 * demarshal functions and return the result. 30 */ 31struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) 32{ 33 switch(header->opcode) { 34 case RBUG_OP_NOOP: 35 return (struct rbug_header *)rbug_demarshal_noop(header); 36 case RBUG_OP_PING: 37 return (struct rbug_header *)rbug_demarshal_ping(header); 38 case RBUG_OP_ERROR: 39 return (struct rbug_header *)rbug_demarshal_error(header); 40 case RBUG_OP_PING_REPLY: 41 return (struct rbug_header *)rbug_demarshal_ping_reply(header); 42 case RBUG_OP_ERROR_REPLY: 43 return (struct rbug_header *)rbug_demarshal_error_reply(header); 44 case RBUG_OP_TEXTURE_LIST: 45 return (struct rbug_header *)rbug_demarshal_texture_list(header); 46 case RBUG_OP_TEXTURE_INFO: 47 return (struct rbug_header *)rbug_demarshal_texture_info(header); 48 case RBUG_OP_TEXTURE_WRITE: 49 return (struct rbug_header *)rbug_demarshal_texture_write(header); 50 case RBUG_OP_TEXTURE_READ: 51 return (struct rbug_header *)rbug_demarshal_texture_read(header); 52 case RBUG_OP_TEXTURE_LIST_REPLY: 53 return (struct rbug_header *)rbug_demarshal_texture_list_reply(header); 54 case RBUG_OP_TEXTURE_INFO_REPLY: 55 return (struct rbug_header *)rbug_demarshal_texture_info_reply(header); 56 case RBUG_OP_TEXTURE_READ_REPLY: 57 return (struct rbug_header *)rbug_demarshal_texture_read_reply(header); 58 case RBUG_OP_CONTEXT_LIST: 59 return (struct rbug_header *)rbug_demarshal_context_list(header); 60 case RBUG_OP_CONTEXT_INFO: 61 return (struct rbug_header *)rbug_demarshal_context_info(header); 62 case RBUG_OP_CONTEXT_DRAW_BLOCK: 63 return (struct rbug_header *)rbug_demarshal_context_draw_block(header); 64 case RBUG_OP_CONTEXT_DRAW_STEP: 65 return (struct rbug_header *)rbug_demarshal_context_draw_step(header); 66 case RBUG_OP_CONTEXT_DRAW_UNBLOCK: 67 return (struct rbug_header *)rbug_demarshal_context_draw_unblock(header); 68 case RBUG_OP_CONTEXT_DRAW_RULE: 69 return (struct rbug_header *)rbug_demarshal_context_draw_rule(header); 70 case RBUG_OP_CONTEXT_FLUSH: 71 return (struct rbug_header *)rbug_demarshal_context_flush(header); 72 case RBUG_OP_CONTEXT_LIST_REPLY: 73 return (struct rbug_header *)rbug_demarshal_context_list_reply(header); 74 case RBUG_OP_CONTEXT_INFO_REPLY: 75 return (struct rbug_header *)rbug_demarshal_context_info_reply(header); 76 case RBUG_OP_CONTEXT_DRAW_BLOCKED: 77 return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header); 78 case RBUG_OP_SHADER_LIST: 79 return (struct rbug_header *)rbug_demarshal_shader_list(header); 80 case RBUG_OP_SHADER_INFO: 81 return (struct rbug_header *)rbug_demarshal_shader_info(header); 82 case RBUG_OP_SHADER_DISABLE: 83 return (struct rbug_header *)rbug_demarshal_shader_disable(header); 84 case RBUG_OP_SHADER_REPLACE: 85 return (struct rbug_header *)rbug_demarshal_shader_replace(header); 86 case RBUG_OP_SHADER_LIST_REPLY: 87 return (struct rbug_header *)rbug_demarshal_shader_list_reply(header); 88 case RBUG_OP_SHADER_INFO_REPLY: 89 return (struct rbug_header *)rbug_demarshal_shader_info_reply(header); 90 default: 91 return NULL; 92 } 93} 94 95const char* rbug_proto_get_name(enum rbug_opcode opcode) 96{ 97 switch(opcode) { 98 case RBUG_OP_NOOP: 99 return "RBUG_OP_NOOP"; 100 case RBUG_OP_PING: 101 return "RBUG_OP_PING"; 102 case RBUG_OP_ERROR: 103 return "RBUG_OP_ERROR"; 104 case RBUG_OP_PING_REPLY: 105 return "RBUG_OP_PING_REPLY"; 106 case RBUG_OP_ERROR_REPLY: 107 return "RBUG_OP_ERROR_REPLY"; 108 case RBUG_OP_TEXTURE_LIST: 109 return "RBUG_OP_TEXTURE_LIST"; 110 case RBUG_OP_TEXTURE_INFO: 111 return "RBUG_OP_TEXTURE_INFO"; 112 case RBUG_OP_TEXTURE_WRITE: 113 return "RBUG_OP_TEXTURE_WRITE"; 114 case RBUG_OP_TEXTURE_READ: 115 return "RBUG_OP_TEXTURE_READ"; 116 case RBUG_OP_TEXTURE_LIST_REPLY: 117 return "RBUG_OP_TEXTURE_LIST_REPLY"; 118 case RBUG_OP_TEXTURE_INFO_REPLY: 119 return "RBUG_OP_TEXTURE_INFO_REPLY"; 120 case RBUG_OP_TEXTURE_READ_REPLY: 121 return "RBUG_OP_TEXTURE_READ_REPLY"; 122 case RBUG_OP_CONTEXT_LIST: 123 return "RBUG_OP_CONTEXT_LIST"; 124 case RBUG_OP_CONTEXT_INFO: 125 return "RBUG_OP_CONTEXT_INFO"; 126 case RBUG_OP_CONTEXT_DRAW_BLOCK: 127 return "RBUG_OP_CONTEXT_DRAW_BLOCK"; 128 case RBUG_OP_CONTEXT_DRAW_STEP: 129 return "RBUG_OP_CONTEXT_DRAW_STEP"; 130 case RBUG_OP_CONTEXT_DRAW_UNBLOCK: 131 return "RBUG_OP_CONTEXT_DRAW_UNBLOCK"; 132 case RBUG_OP_CONTEXT_DRAW_RULE: 133 return "RBUG_OP_CONTEXT_DRAW_RULE"; 134 case RBUG_OP_CONTEXT_FLUSH: 135 return "RBUG_OP_CONTEXT_FLUSH"; 136 case RBUG_OP_CONTEXT_LIST_REPLY: 137 return "RBUG_OP_CONTEXT_LIST_REPLY"; 138 case RBUG_OP_CONTEXT_INFO_REPLY: 139 return "RBUG_OP_CONTEXT_INFO_REPLY"; 140 case RBUG_OP_CONTEXT_DRAW_BLOCKED: 141 return "RBUG_OP_CONTEXT_DRAW_BLOCKED"; 142 case RBUG_OP_SHADER_LIST: 143 return "RBUG_OP_SHADER_LIST"; 144 case RBUG_OP_SHADER_INFO: 145 return "RBUG_OP_SHADER_INFO"; 146 case RBUG_OP_SHADER_DISABLE: 147 return "RBUG_OP_SHADER_DISABLE"; 148 case RBUG_OP_SHADER_REPLACE: 149 return "RBUG_OP_SHADER_REPLACE"; 150 case RBUG_OP_SHADER_LIST_REPLY: 151 return "RBUG_OP_SHADER_LIST_REPLY"; 152 case RBUG_OP_SHADER_INFO_REPLY: 153 return "RBUG_OP_SHADER_INFO_REPLY"; 154 default: 155 return NULL; 156 } 157} 158