14a49301eSmrg/* 24a49301eSmrg * Copyright 2009 VMware, Inc. 34a49301eSmrg * All Rights Reserved. 44a49301eSmrg * 54a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a 64a49301eSmrg * copy of this software and associated documentation files (the "Software"), 74a49301eSmrg * to deal in the Software without restriction, including without limitation 84a49301eSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub 94a49301eSmrg * license, and/or sell copies of the Software, and to permit persons to whom 104a49301eSmrg * the Software is furnished to do so, subject to the following conditions: 114a49301eSmrg * 124a49301eSmrg * The above copyright notice and this permission notice (including the next 134a49301eSmrg * paragraph) shall be included in all copies or substantial portions of the 144a49301eSmrg * Software. 154a49301eSmrg * 164a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 174a49301eSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 184a49301eSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 194a49301eSmrg * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 204a49301eSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 214a49301eSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 224a49301eSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 234a49301eSmrg */ 244a49301eSmrg 254a49301eSmrg#include "rbug.h" 264a49301eSmrg 274a49301eSmrg/** 284a49301eSmrg * Small function that looks at the proto_header and selects the correct 294a49301eSmrg * demarshal functions and return the result. 304a49301eSmrg */ 314a49301eSmrgstruct rbug_header * rbug_demarshal(struct rbug_proto_header *header) 324a49301eSmrg{ 334a49301eSmrg switch(header->opcode) { 344a49301eSmrg case RBUG_OP_NOOP: 354a49301eSmrg return (struct rbug_header *)rbug_demarshal_noop(header); 364a49301eSmrg case RBUG_OP_PING: 374a49301eSmrg return (struct rbug_header *)rbug_demarshal_ping(header); 384a49301eSmrg case RBUG_OP_ERROR: 394a49301eSmrg return (struct rbug_header *)rbug_demarshal_error(header); 404a49301eSmrg case RBUG_OP_PING_REPLY: 414a49301eSmrg return (struct rbug_header *)rbug_demarshal_ping_reply(header); 424a49301eSmrg case RBUG_OP_ERROR_REPLY: 434a49301eSmrg return (struct rbug_header *)rbug_demarshal_error_reply(header); 444a49301eSmrg case RBUG_OP_TEXTURE_LIST: 454a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_list(header); 464a49301eSmrg case RBUG_OP_TEXTURE_INFO: 474a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_info(header); 484a49301eSmrg case RBUG_OP_TEXTURE_WRITE: 494a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_write(header); 504a49301eSmrg case RBUG_OP_TEXTURE_READ: 514a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_read(header); 524a49301eSmrg case RBUG_OP_TEXTURE_LIST_REPLY: 534a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_list_reply(header); 544a49301eSmrg case RBUG_OP_TEXTURE_INFO_REPLY: 554a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_info_reply(header); 564a49301eSmrg case RBUG_OP_TEXTURE_READ_REPLY: 574a49301eSmrg return (struct rbug_header *)rbug_demarshal_texture_read_reply(header); 584a49301eSmrg case RBUG_OP_CONTEXT_LIST: 594a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_list(header); 604a49301eSmrg case RBUG_OP_CONTEXT_INFO: 614a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_info(header); 624a49301eSmrg case RBUG_OP_CONTEXT_DRAW_BLOCK: 634a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_draw_block(header); 644a49301eSmrg case RBUG_OP_CONTEXT_DRAW_STEP: 654a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_draw_step(header); 664a49301eSmrg case RBUG_OP_CONTEXT_DRAW_UNBLOCK: 674a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_draw_unblock(header); 684a49301eSmrg case RBUG_OP_CONTEXT_DRAW_RULE: 694a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_draw_rule(header); 704a49301eSmrg case RBUG_OP_CONTEXT_FLUSH: 714a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_flush(header); 724a49301eSmrg case RBUG_OP_CONTEXT_LIST_REPLY: 734a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_list_reply(header); 744a49301eSmrg case RBUG_OP_CONTEXT_INFO_REPLY: 754a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_info_reply(header); 764a49301eSmrg case RBUG_OP_CONTEXT_DRAW_BLOCKED: 774a49301eSmrg return (struct rbug_header *)rbug_demarshal_context_draw_blocked(header); 784a49301eSmrg case RBUG_OP_SHADER_LIST: 794a49301eSmrg return (struct rbug_header *)rbug_demarshal_shader_list(header); 804a49301eSmrg case RBUG_OP_SHADER_INFO: 814a49301eSmrg return (struct rbug_header *)rbug_demarshal_shader_info(header); 824a49301eSmrg case RBUG_OP_SHADER_DISABLE: 834a49301eSmrg return (struct rbug_header *)rbug_demarshal_shader_disable(header); 844a49301eSmrg case RBUG_OP_SHADER_REPLACE: 854a49301eSmrg return (struct rbug_header *)rbug_demarshal_shader_replace(header); 864a49301eSmrg case RBUG_OP_SHADER_LIST_REPLY: 874a49301eSmrg return (struct rbug_header *)rbug_demarshal_shader_list_reply(header); 884a49301eSmrg case RBUG_OP_SHADER_INFO_REPLY: 894a49301eSmrg return (struct rbug_header *)rbug_demarshal_shader_info_reply(header); 904a49301eSmrg default: 914a49301eSmrg return NULL; 924a49301eSmrg } 934a49301eSmrg} 943464ebd5Sriastradh 953464ebd5Sriastradhconst char* rbug_proto_get_name(enum rbug_opcode opcode) 963464ebd5Sriastradh{ 973464ebd5Sriastradh switch(opcode) { 983464ebd5Sriastradh case RBUG_OP_NOOP: 993464ebd5Sriastradh return "RBUG_OP_NOOP"; 1003464ebd5Sriastradh case RBUG_OP_PING: 1013464ebd5Sriastradh return "RBUG_OP_PING"; 1023464ebd5Sriastradh case RBUG_OP_ERROR: 1033464ebd5Sriastradh return "RBUG_OP_ERROR"; 1043464ebd5Sriastradh case RBUG_OP_PING_REPLY: 1053464ebd5Sriastradh return "RBUG_OP_PING_REPLY"; 1063464ebd5Sriastradh case RBUG_OP_ERROR_REPLY: 1073464ebd5Sriastradh return "RBUG_OP_ERROR_REPLY"; 1083464ebd5Sriastradh case RBUG_OP_TEXTURE_LIST: 1093464ebd5Sriastradh return "RBUG_OP_TEXTURE_LIST"; 1103464ebd5Sriastradh case RBUG_OP_TEXTURE_INFO: 1113464ebd5Sriastradh return "RBUG_OP_TEXTURE_INFO"; 1123464ebd5Sriastradh case RBUG_OP_TEXTURE_WRITE: 1133464ebd5Sriastradh return "RBUG_OP_TEXTURE_WRITE"; 1143464ebd5Sriastradh case RBUG_OP_TEXTURE_READ: 1153464ebd5Sriastradh return "RBUG_OP_TEXTURE_READ"; 1163464ebd5Sriastradh case RBUG_OP_TEXTURE_LIST_REPLY: 1173464ebd5Sriastradh return "RBUG_OP_TEXTURE_LIST_REPLY"; 1183464ebd5Sriastradh case RBUG_OP_TEXTURE_INFO_REPLY: 1193464ebd5Sriastradh return "RBUG_OP_TEXTURE_INFO_REPLY"; 1203464ebd5Sriastradh case RBUG_OP_TEXTURE_READ_REPLY: 1213464ebd5Sriastradh return "RBUG_OP_TEXTURE_READ_REPLY"; 1223464ebd5Sriastradh case RBUG_OP_CONTEXT_LIST: 1233464ebd5Sriastradh return "RBUG_OP_CONTEXT_LIST"; 1243464ebd5Sriastradh case RBUG_OP_CONTEXT_INFO: 1253464ebd5Sriastradh return "RBUG_OP_CONTEXT_INFO"; 1263464ebd5Sriastradh case RBUG_OP_CONTEXT_DRAW_BLOCK: 1273464ebd5Sriastradh return "RBUG_OP_CONTEXT_DRAW_BLOCK"; 1283464ebd5Sriastradh case RBUG_OP_CONTEXT_DRAW_STEP: 1293464ebd5Sriastradh return "RBUG_OP_CONTEXT_DRAW_STEP"; 1303464ebd5Sriastradh case RBUG_OP_CONTEXT_DRAW_UNBLOCK: 1313464ebd5Sriastradh return "RBUG_OP_CONTEXT_DRAW_UNBLOCK"; 1323464ebd5Sriastradh case RBUG_OP_CONTEXT_DRAW_RULE: 1333464ebd5Sriastradh return "RBUG_OP_CONTEXT_DRAW_RULE"; 1343464ebd5Sriastradh case RBUG_OP_CONTEXT_FLUSH: 1353464ebd5Sriastradh return "RBUG_OP_CONTEXT_FLUSH"; 1363464ebd5Sriastradh case RBUG_OP_CONTEXT_LIST_REPLY: 1373464ebd5Sriastradh return "RBUG_OP_CONTEXT_LIST_REPLY"; 1383464ebd5Sriastradh case RBUG_OP_CONTEXT_INFO_REPLY: 1393464ebd5Sriastradh return "RBUG_OP_CONTEXT_INFO_REPLY"; 1403464ebd5Sriastradh case RBUG_OP_CONTEXT_DRAW_BLOCKED: 1413464ebd5Sriastradh return "RBUG_OP_CONTEXT_DRAW_BLOCKED"; 1423464ebd5Sriastradh case RBUG_OP_SHADER_LIST: 1433464ebd5Sriastradh return "RBUG_OP_SHADER_LIST"; 1443464ebd5Sriastradh case RBUG_OP_SHADER_INFO: 1453464ebd5Sriastradh return "RBUG_OP_SHADER_INFO"; 1463464ebd5Sriastradh case RBUG_OP_SHADER_DISABLE: 1473464ebd5Sriastradh return "RBUG_OP_SHADER_DISABLE"; 1483464ebd5Sriastradh case RBUG_OP_SHADER_REPLACE: 1493464ebd5Sriastradh return "RBUG_OP_SHADER_REPLACE"; 1503464ebd5Sriastradh case RBUG_OP_SHADER_LIST_REPLY: 1513464ebd5Sriastradh return "RBUG_OP_SHADER_LIST_REPLY"; 1523464ebd5Sriastradh case RBUG_OP_SHADER_INFO_REPLY: 1533464ebd5Sriastradh return "RBUG_OP_SHADER_INFO_REPLY"; 1543464ebd5Sriastradh default: 1553464ebd5Sriastradh return NULL; 1563464ebd5Sriastradh } 1573464ebd5Sriastradh} 158