1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2009 VMware, Inc. 3bf215546Sopenharmony_ci * All Rights Reserved. 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 9bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 10bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * VMWARE AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 20bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 22bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci/* 26bf215546Sopenharmony_ci * This file holds the function implementation for one of the rbug extensions. 27bf215546Sopenharmony_ci * Prototypes and declerations of functions and structs is in the same folder 28bf215546Sopenharmony_ci * in the header file matching this file's name. 29bf215546Sopenharmony_ci * 30bf215546Sopenharmony_ci * The functions starting rbug_send_* encodes a call to the write format and 31bf215546Sopenharmony_ci * sends that to the supplied connection, while functions starting with 32bf215546Sopenharmony_ci * rbug_demarshal_* demarshal data in the wire protocol. 33bf215546Sopenharmony_ci * 34bf215546Sopenharmony_ci * Functions ending with _reply are replies to requests. 35bf215546Sopenharmony_ci */ 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci#include "rbug_internal.h" 38bf215546Sopenharmony_ci#include "rbug_context.h" 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ciint rbug_send_context_list(struct rbug_connection *__con, 41bf215546Sopenharmony_ci uint32_t *__serial) 42bf215546Sopenharmony_ci{ 43bf215546Sopenharmony_ci uint32_t __len = 0; 44bf215546Sopenharmony_ci uint32_t __pos = 0; 45bf215546Sopenharmony_ci uint8_t *__data = NULL; 46bf215546Sopenharmony_ci int __ret = 0; 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci LEN(8); /* header */ 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci /* align */ 51bf215546Sopenharmony_ci PAD(__len, 8); 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 54bf215546Sopenharmony_ci if (!__data) 55bf215546Sopenharmony_ci return -ENOMEM; 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST)); 58bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci /* final pad */ 61bf215546Sopenharmony_ci PAD(__pos, 8); 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci if (__pos != __len) { 64bf215546Sopenharmony_ci __ret = -EINVAL; 65bf215546Sopenharmony_ci } else { 66bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST, __len); 67bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 68bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 69bf215546Sopenharmony_ci } 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci FREE(__data); 72bf215546Sopenharmony_ci return __ret; 73bf215546Sopenharmony_ci} 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ciint rbug_send_context_info(struct rbug_connection *__con, 76bf215546Sopenharmony_ci rbug_context_t context, 77bf215546Sopenharmony_ci uint32_t *__serial) 78bf215546Sopenharmony_ci{ 79bf215546Sopenharmony_ci uint32_t __len = 0; 80bf215546Sopenharmony_ci uint32_t __pos = 0; 81bf215546Sopenharmony_ci uint8_t *__data = NULL; 82bf215546Sopenharmony_ci int __ret = 0; 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci LEN(8); /* header */ 85bf215546Sopenharmony_ci LEN(8); /* context */ 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_ci /* align */ 88bf215546Sopenharmony_ci PAD(__len, 8); 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 91bf215546Sopenharmony_ci if (!__data) 92bf215546Sopenharmony_ci return -ENOMEM; 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO)); 95bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 96bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci /* final pad */ 99bf215546Sopenharmony_ci PAD(__pos, 8); 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_ci if (__pos != __len) { 102bf215546Sopenharmony_ci __ret = -EINVAL; 103bf215546Sopenharmony_ci } else { 104bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO, __len); 105bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 106bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 107bf215546Sopenharmony_ci } 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci FREE(__data); 110bf215546Sopenharmony_ci return __ret; 111bf215546Sopenharmony_ci} 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ciint rbug_send_context_draw_block(struct rbug_connection *__con, 114bf215546Sopenharmony_ci rbug_context_t context, 115bf215546Sopenharmony_ci rbug_block_t block, 116bf215546Sopenharmony_ci uint32_t *__serial) 117bf215546Sopenharmony_ci{ 118bf215546Sopenharmony_ci uint32_t __len = 0; 119bf215546Sopenharmony_ci uint32_t __pos = 0; 120bf215546Sopenharmony_ci uint8_t *__data = NULL; 121bf215546Sopenharmony_ci int __ret = 0; 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_ci LEN(8); /* header */ 124bf215546Sopenharmony_ci LEN(8); /* context */ 125bf215546Sopenharmony_ci LEN(4); /* block */ 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ci /* align */ 128bf215546Sopenharmony_ci PAD(__len, 8); 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 131bf215546Sopenharmony_ci if (!__data) 132bf215546Sopenharmony_ci return -ENOMEM; 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK)); 135bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 136bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 137bf215546Sopenharmony_ci WRITE(4, rbug_block_t, block); /* block */ 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_ci /* final pad */ 140bf215546Sopenharmony_ci PAD(__pos, 8); 141bf215546Sopenharmony_ci 142bf215546Sopenharmony_ci if (__pos != __len) { 143bf215546Sopenharmony_ci __ret = -EINVAL; 144bf215546Sopenharmony_ci } else { 145bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCK, __len); 146bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 147bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 148bf215546Sopenharmony_ci } 149bf215546Sopenharmony_ci 150bf215546Sopenharmony_ci FREE(__data); 151bf215546Sopenharmony_ci return __ret; 152bf215546Sopenharmony_ci} 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_ciint rbug_send_context_draw_step(struct rbug_connection *__con, 155bf215546Sopenharmony_ci rbug_context_t context, 156bf215546Sopenharmony_ci rbug_block_t step, 157bf215546Sopenharmony_ci uint32_t *__serial) 158bf215546Sopenharmony_ci{ 159bf215546Sopenharmony_ci uint32_t __len = 0; 160bf215546Sopenharmony_ci uint32_t __pos = 0; 161bf215546Sopenharmony_ci uint8_t *__data = NULL; 162bf215546Sopenharmony_ci int __ret = 0; 163bf215546Sopenharmony_ci 164bf215546Sopenharmony_ci LEN(8); /* header */ 165bf215546Sopenharmony_ci LEN(8); /* context */ 166bf215546Sopenharmony_ci LEN(4); /* step */ 167bf215546Sopenharmony_ci 168bf215546Sopenharmony_ci /* align */ 169bf215546Sopenharmony_ci PAD(__len, 8); 170bf215546Sopenharmony_ci 171bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 172bf215546Sopenharmony_ci if (!__data) 173bf215546Sopenharmony_ci return -ENOMEM; 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_STEP)); 176bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 177bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 178bf215546Sopenharmony_ci WRITE(4, rbug_block_t, step); /* step */ 179bf215546Sopenharmony_ci 180bf215546Sopenharmony_ci /* final pad */ 181bf215546Sopenharmony_ci PAD(__pos, 8); 182bf215546Sopenharmony_ci 183bf215546Sopenharmony_ci if (__pos != __len) { 184bf215546Sopenharmony_ci __ret = -EINVAL; 185bf215546Sopenharmony_ci } else { 186bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_STEP, __len); 187bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 188bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 189bf215546Sopenharmony_ci } 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci FREE(__data); 192bf215546Sopenharmony_ci return __ret; 193bf215546Sopenharmony_ci} 194bf215546Sopenharmony_ci 195bf215546Sopenharmony_ciint rbug_send_context_draw_unblock(struct rbug_connection *__con, 196bf215546Sopenharmony_ci rbug_context_t context, 197bf215546Sopenharmony_ci rbug_block_t unblock, 198bf215546Sopenharmony_ci uint32_t *__serial) 199bf215546Sopenharmony_ci{ 200bf215546Sopenharmony_ci uint32_t __len = 0; 201bf215546Sopenharmony_ci uint32_t __pos = 0; 202bf215546Sopenharmony_ci uint8_t *__data = NULL; 203bf215546Sopenharmony_ci int __ret = 0; 204bf215546Sopenharmony_ci 205bf215546Sopenharmony_ci LEN(8); /* header */ 206bf215546Sopenharmony_ci LEN(8); /* context */ 207bf215546Sopenharmony_ci LEN(4); /* unblock */ 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_ci /* align */ 210bf215546Sopenharmony_ci PAD(__len, 8); 211bf215546Sopenharmony_ci 212bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 213bf215546Sopenharmony_ci if (!__data) 214bf215546Sopenharmony_ci return -ENOMEM; 215bf215546Sopenharmony_ci 216bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK)); 217bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 218bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 219bf215546Sopenharmony_ci WRITE(4, rbug_block_t, unblock); /* unblock */ 220bf215546Sopenharmony_ci 221bf215546Sopenharmony_ci /* final pad */ 222bf215546Sopenharmony_ci PAD(__pos, 8); 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_ci if (__pos != __len) { 225bf215546Sopenharmony_ci __ret = -EINVAL; 226bf215546Sopenharmony_ci } else { 227bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_UNBLOCK, __len); 228bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 229bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 230bf215546Sopenharmony_ci } 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ci FREE(__data); 233bf215546Sopenharmony_ci return __ret; 234bf215546Sopenharmony_ci} 235bf215546Sopenharmony_ci 236bf215546Sopenharmony_ciint rbug_send_context_draw_rule(struct rbug_connection *__con, 237bf215546Sopenharmony_ci rbug_context_t context, 238bf215546Sopenharmony_ci rbug_shader_t vertex, 239bf215546Sopenharmony_ci rbug_shader_t fragment, 240bf215546Sopenharmony_ci rbug_texture_t texture, 241bf215546Sopenharmony_ci rbug_texture_t surface, 242bf215546Sopenharmony_ci rbug_block_t block, 243bf215546Sopenharmony_ci uint32_t *__serial) 244bf215546Sopenharmony_ci{ 245bf215546Sopenharmony_ci uint32_t __len = 0; 246bf215546Sopenharmony_ci uint32_t __pos = 0; 247bf215546Sopenharmony_ci uint8_t *__data = NULL; 248bf215546Sopenharmony_ci int __ret = 0; 249bf215546Sopenharmony_ci 250bf215546Sopenharmony_ci LEN(8); /* header */ 251bf215546Sopenharmony_ci LEN(8); /* context */ 252bf215546Sopenharmony_ci LEN(8); /* vertex */ 253bf215546Sopenharmony_ci LEN(8); /* fragment */ 254bf215546Sopenharmony_ci LEN(8); /* texture */ 255bf215546Sopenharmony_ci LEN(8); /* surface */ 256bf215546Sopenharmony_ci LEN(4); /* block */ 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ci /* align */ 259bf215546Sopenharmony_ci PAD(__len, 8); 260bf215546Sopenharmony_ci 261bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 262bf215546Sopenharmony_ci if (!__data) 263bf215546Sopenharmony_ci return -ENOMEM; 264bf215546Sopenharmony_ci 265bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_RULE)); 266bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 267bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 268bf215546Sopenharmony_ci WRITE(8, rbug_shader_t, vertex); /* vertex */ 269bf215546Sopenharmony_ci WRITE(8, rbug_shader_t, fragment); /* fragment */ 270bf215546Sopenharmony_ci WRITE(8, rbug_texture_t, texture); /* texture */ 271bf215546Sopenharmony_ci WRITE(8, rbug_texture_t, surface); /* surface */ 272bf215546Sopenharmony_ci WRITE(4, rbug_block_t, block); /* block */ 273bf215546Sopenharmony_ci 274bf215546Sopenharmony_ci /* final pad */ 275bf215546Sopenharmony_ci PAD(__pos, 8); 276bf215546Sopenharmony_ci 277bf215546Sopenharmony_ci if (__pos != __len) { 278bf215546Sopenharmony_ci __ret = -EINVAL; 279bf215546Sopenharmony_ci } else { 280bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_RULE, __len); 281bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 282bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 283bf215546Sopenharmony_ci } 284bf215546Sopenharmony_ci 285bf215546Sopenharmony_ci FREE(__data); 286bf215546Sopenharmony_ci return __ret; 287bf215546Sopenharmony_ci} 288bf215546Sopenharmony_ci 289bf215546Sopenharmony_ciint rbug_send_context_flush(struct rbug_connection *__con, 290bf215546Sopenharmony_ci rbug_context_t context, 291bf215546Sopenharmony_ci uint32_t *__serial) 292bf215546Sopenharmony_ci{ 293bf215546Sopenharmony_ci uint32_t __len = 0; 294bf215546Sopenharmony_ci uint32_t __pos = 0; 295bf215546Sopenharmony_ci uint8_t *__data = NULL; 296bf215546Sopenharmony_ci int __ret = 0; 297bf215546Sopenharmony_ci 298bf215546Sopenharmony_ci LEN(8); /* header */ 299bf215546Sopenharmony_ci LEN(8); /* context */ 300bf215546Sopenharmony_ci 301bf215546Sopenharmony_ci /* align */ 302bf215546Sopenharmony_ci PAD(__len, 8); 303bf215546Sopenharmony_ci 304bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 305bf215546Sopenharmony_ci if (!__data) 306bf215546Sopenharmony_ci return -ENOMEM; 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_FLUSH)); 309bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 310bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 311bf215546Sopenharmony_ci 312bf215546Sopenharmony_ci /* final pad */ 313bf215546Sopenharmony_ci PAD(__pos, 8); 314bf215546Sopenharmony_ci 315bf215546Sopenharmony_ci if (__pos != __len) { 316bf215546Sopenharmony_ci __ret = -EINVAL; 317bf215546Sopenharmony_ci } else { 318bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_FLUSH, __len); 319bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 320bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 321bf215546Sopenharmony_ci } 322bf215546Sopenharmony_ci 323bf215546Sopenharmony_ci FREE(__data); 324bf215546Sopenharmony_ci return __ret; 325bf215546Sopenharmony_ci} 326bf215546Sopenharmony_ci 327bf215546Sopenharmony_ciint rbug_send_context_list_reply(struct rbug_connection *__con, 328bf215546Sopenharmony_ci uint32_t serial, 329bf215546Sopenharmony_ci rbug_context_t *contexts, 330bf215546Sopenharmony_ci uint32_t contexts_len, 331bf215546Sopenharmony_ci uint32_t *__serial) 332bf215546Sopenharmony_ci{ 333bf215546Sopenharmony_ci uint32_t __len = 0; 334bf215546Sopenharmony_ci uint32_t __pos = 0; 335bf215546Sopenharmony_ci uint8_t *__data = NULL; 336bf215546Sopenharmony_ci int __ret = 0; 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_ci LEN(8); /* header */ 339bf215546Sopenharmony_ci LEN(4); /* serial */ 340bf215546Sopenharmony_ci LEN_ARRAY(8, contexts); /* contexts */ 341bf215546Sopenharmony_ci 342bf215546Sopenharmony_ci /* align */ 343bf215546Sopenharmony_ci PAD(__len, 8); 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 346bf215546Sopenharmony_ci if (!__data) 347bf215546Sopenharmony_ci return -ENOMEM; 348bf215546Sopenharmony_ci 349bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY)); 350bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 351bf215546Sopenharmony_ci WRITE(4, uint32_t, serial); /* serial */ 352bf215546Sopenharmony_ci WRITE_ARRAY(8, rbug_context_t, contexts); /* contexts */ 353bf215546Sopenharmony_ci 354bf215546Sopenharmony_ci /* final pad */ 355bf215546Sopenharmony_ci PAD(__pos, 8); 356bf215546Sopenharmony_ci 357bf215546Sopenharmony_ci if (__pos != __len) { 358bf215546Sopenharmony_ci __ret = -EINVAL; 359bf215546Sopenharmony_ci } else { 360bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST_REPLY, __len); 361bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 362bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 363bf215546Sopenharmony_ci } 364bf215546Sopenharmony_ci 365bf215546Sopenharmony_ci FREE(__data); 366bf215546Sopenharmony_ci return __ret; 367bf215546Sopenharmony_ci} 368bf215546Sopenharmony_ci 369bf215546Sopenharmony_ciint rbug_send_context_info_reply(struct rbug_connection *__con, 370bf215546Sopenharmony_ci uint32_t serial, 371bf215546Sopenharmony_ci rbug_shader_t vertex, 372bf215546Sopenharmony_ci rbug_shader_t fragment, 373bf215546Sopenharmony_ci rbug_texture_t *texs, 374bf215546Sopenharmony_ci uint32_t texs_len, 375bf215546Sopenharmony_ci rbug_texture_t *cbufs, 376bf215546Sopenharmony_ci uint32_t cbufs_len, 377bf215546Sopenharmony_ci rbug_texture_t zsbuf, 378bf215546Sopenharmony_ci rbug_block_t blocker, 379bf215546Sopenharmony_ci rbug_block_t blocked, 380bf215546Sopenharmony_ci uint32_t *__serial) 381bf215546Sopenharmony_ci{ 382bf215546Sopenharmony_ci uint32_t __len = 0; 383bf215546Sopenharmony_ci uint32_t __pos = 0; 384bf215546Sopenharmony_ci uint8_t *__data = NULL; 385bf215546Sopenharmony_ci int __ret = 0; 386bf215546Sopenharmony_ci 387bf215546Sopenharmony_ci LEN(8); /* header */ 388bf215546Sopenharmony_ci LEN(4); /* serial */ 389bf215546Sopenharmony_ci LEN(8); /* vertex */ 390bf215546Sopenharmony_ci LEN(8); /* fragment */ 391bf215546Sopenharmony_ci LEN_ARRAY(8, texs); /* texs */ 392bf215546Sopenharmony_ci LEN_ARRAY(8, cbufs); /* cbufs */ 393bf215546Sopenharmony_ci LEN(8); /* zsbuf */ 394bf215546Sopenharmony_ci LEN(4); /* blocker */ 395bf215546Sopenharmony_ci LEN(4); /* blocked */ 396bf215546Sopenharmony_ci 397bf215546Sopenharmony_ci /* align */ 398bf215546Sopenharmony_ci PAD(__len, 8); 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 401bf215546Sopenharmony_ci if (!__data) 402bf215546Sopenharmony_ci return -ENOMEM; 403bf215546Sopenharmony_ci 404bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY)); 405bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 406bf215546Sopenharmony_ci WRITE(4, uint32_t, serial); /* serial */ 407bf215546Sopenharmony_ci WRITE(8, rbug_shader_t, vertex); /* vertex */ 408bf215546Sopenharmony_ci WRITE(8, rbug_shader_t, fragment); /* fragment */ 409bf215546Sopenharmony_ci WRITE_ARRAY(8, rbug_texture_t, texs); /* texs */ 410bf215546Sopenharmony_ci WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ 411bf215546Sopenharmony_ci WRITE(8, rbug_texture_t, zsbuf); /* zsbuf */ 412bf215546Sopenharmony_ci WRITE(4, rbug_block_t, blocker); /* blocker */ 413bf215546Sopenharmony_ci WRITE(4, rbug_block_t, blocked); /* blocked */ 414bf215546Sopenharmony_ci 415bf215546Sopenharmony_ci /* final pad */ 416bf215546Sopenharmony_ci PAD(__pos, 8); 417bf215546Sopenharmony_ci 418bf215546Sopenharmony_ci if (__pos != __len) { 419bf215546Sopenharmony_ci __ret = -EINVAL; 420bf215546Sopenharmony_ci } else { 421bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO_REPLY, __len); 422bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 423bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 424bf215546Sopenharmony_ci } 425bf215546Sopenharmony_ci 426bf215546Sopenharmony_ci FREE(__data); 427bf215546Sopenharmony_ci return __ret; 428bf215546Sopenharmony_ci} 429bf215546Sopenharmony_ci 430bf215546Sopenharmony_ciint rbug_send_context_draw_blocked(struct rbug_connection *__con, 431bf215546Sopenharmony_ci rbug_context_t context, 432bf215546Sopenharmony_ci rbug_block_t block, 433bf215546Sopenharmony_ci uint32_t *__serial) 434bf215546Sopenharmony_ci{ 435bf215546Sopenharmony_ci uint32_t __len = 0; 436bf215546Sopenharmony_ci uint32_t __pos = 0; 437bf215546Sopenharmony_ci uint8_t *__data = NULL; 438bf215546Sopenharmony_ci int __ret = 0; 439bf215546Sopenharmony_ci 440bf215546Sopenharmony_ci LEN(8); /* header */ 441bf215546Sopenharmony_ci LEN(8); /* context */ 442bf215546Sopenharmony_ci LEN(4); /* block */ 443bf215546Sopenharmony_ci 444bf215546Sopenharmony_ci /* align */ 445bf215546Sopenharmony_ci PAD(__len, 8); 446bf215546Sopenharmony_ci 447bf215546Sopenharmony_ci __data = (uint8_t*)MALLOC(__len); 448bf215546Sopenharmony_ci if (!__data) 449bf215546Sopenharmony_ci return -ENOMEM; 450bf215546Sopenharmony_ci 451bf215546Sopenharmony_ci WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED)); 452bf215546Sopenharmony_ci WRITE(4, uint32_t, ((uint32_t)(__len / 4))); 453bf215546Sopenharmony_ci WRITE(8, rbug_context_t, context); /* context */ 454bf215546Sopenharmony_ci WRITE(4, rbug_block_t, block); /* block */ 455bf215546Sopenharmony_ci 456bf215546Sopenharmony_ci /* final pad */ 457bf215546Sopenharmony_ci PAD(__pos, 8); 458bf215546Sopenharmony_ci 459bf215546Sopenharmony_ci if (__pos != __len) { 460bf215546Sopenharmony_ci __ret = -EINVAL; 461bf215546Sopenharmony_ci } else { 462bf215546Sopenharmony_ci rbug_connection_send_start(__con, RBUG_OP_CONTEXT_DRAW_BLOCKED, __len); 463bf215546Sopenharmony_ci rbug_connection_write(__con, __data, __len); 464bf215546Sopenharmony_ci __ret = rbug_connection_send_finish(__con, __serial); 465bf215546Sopenharmony_ci } 466bf215546Sopenharmony_ci 467bf215546Sopenharmony_ci FREE(__data); 468bf215546Sopenharmony_ci return __ret; 469bf215546Sopenharmony_ci} 470bf215546Sopenharmony_ci 471bf215546Sopenharmony_cistruct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header) 472bf215546Sopenharmony_ci{ 473bf215546Sopenharmony_ci struct rbug_proto_context_list *ret; 474bf215546Sopenharmony_ci 475bf215546Sopenharmony_ci if (!header) 476bf215546Sopenharmony_ci return NULL; 477bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST) 478bf215546Sopenharmony_ci return NULL; 479bf215546Sopenharmony_ci 480bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 481bf215546Sopenharmony_ci if (!ret) 482bf215546Sopenharmony_ci return NULL; 483bf215546Sopenharmony_ci 484bf215546Sopenharmony_ci ret->header.__message = header; 485bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 486bf215546Sopenharmony_ci 487bf215546Sopenharmony_ci return ret; 488bf215546Sopenharmony_ci} 489bf215546Sopenharmony_ci 490bf215546Sopenharmony_cistruct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header) 491bf215546Sopenharmony_ci{ 492bf215546Sopenharmony_ci uint32_t len = 0; 493bf215546Sopenharmony_ci uint32_t pos = 0; 494bf215546Sopenharmony_ci uint8_t *data = NULL; 495bf215546Sopenharmony_ci struct rbug_proto_context_info *ret; 496bf215546Sopenharmony_ci 497bf215546Sopenharmony_ci if (!header) 498bf215546Sopenharmony_ci return NULL; 499bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO) 500bf215546Sopenharmony_ci return NULL; 501bf215546Sopenharmony_ci 502bf215546Sopenharmony_ci pos = 0; 503bf215546Sopenharmony_ci len = header->length * 4; 504bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 505bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 506bf215546Sopenharmony_ci if (!ret) 507bf215546Sopenharmony_ci return NULL; 508bf215546Sopenharmony_ci 509bf215546Sopenharmony_ci ret->header.__message = header; 510bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 511bf215546Sopenharmony_ci 512bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 513bf215546Sopenharmony_ci 514bf215546Sopenharmony_ci return ret; 515bf215546Sopenharmony_ci} 516bf215546Sopenharmony_ci 517bf215546Sopenharmony_cistruct rbug_proto_context_draw_block * rbug_demarshal_context_draw_block(struct rbug_proto_header *header) 518bf215546Sopenharmony_ci{ 519bf215546Sopenharmony_ci uint32_t len = 0; 520bf215546Sopenharmony_ci uint32_t pos = 0; 521bf215546Sopenharmony_ci uint8_t *data = NULL; 522bf215546Sopenharmony_ci struct rbug_proto_context_draw_block *ret; 523bf215546Sopenharmony_ci 524bf215546Sopenharmony_ci if (!header) 525bf215546Sopenharmony_ci return NULL; 526bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCK) 527bf215546Sopenharmony_ci return NULL; 528bf215546Sopenharmony_ci 529bf215546Sopenharmony_ci pos = 0; 530bf215546Sopenharmony_ci len = header->length * 4; 531bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 532bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 533bf215546Sopenharmony_ci if (!ret) 534bf215546Sopenharmony_ci return NULL; 535bf215546Sopenharmony_ci 536bf215546Sopenharmony_ci ret->header.__message = header; 537bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 538bf215546Sopenharmony_ci 539bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 540bf215546Sopenharmony_ci READ(4, rbug_block_t, block); /* block */ 541bf215546Sopenharmony_ci 542bf215546Sopenharmony_ci return ret; 543bf215546Sopenharmony_ci} 544bf215546Sopenharmony_ci 545bf215546Sopenharmony_cistruct rbug_proto_context_draw_step * rbug_demarshal_context_draw_step(struct rbug_proto_header *header) 546bf215546Sopenharmony_ci{ 547bf215546Sopenharmony_ci uint32_t len = 0; 548bf215546Sopenharmony_ci uint32_t pos = 0; 549bf215546Sopenharmony_ci uint8_t *data = NULL; 550bf215546Sopenharmony_ci struct rbug_proto_context_draw_step *ret; 551bf215546Sopenharmony_ci 552bf215546Sopenharmony_ci if (!header) 553bf215546Sopenharmony_ci return NULL; 554bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_STEP) 555bf215546Sopenharmony_ci return NULL; 556bf215546Sopenharmony_ci 557bf215546Sopenharmony_ci pos = 0; 558bf215546Sopenharmony_ci len = header->length * 4; 559bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 560bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 561bf215546Sopenharmony_ci if (!ret) 562bf215546Sopenharmony_ci return NULL; 563bf215546Sopenharmony_ci 564bf215546Sopenharmony_ci ret->header.__message = header; 565bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 566bf215546Sopenharmony_ci 567bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 568bf215546Sopenharmony_ci READ(4, rbug_block_t, step); /* step */ 569bf215546Sopenharmony_ci 570bf215546Sopenharmony_ci return ret; 571bf215546Sopenharmony_ci} 572bf215546Sopenharmony_ci 573bf215546Sopenharmony_cistruct rbug_proto_context_draw_unblock * rbug_demarshal_context_draw_unblock(struct rbug_proto_header *header) 574bf215546Sopenharmony_ci{ 575bf215546Sopenharmony_ci uint32_t len = 0; 576bf215546Sopenharmony_ci uint32_t pos = 0; 577bf215546Sopenharmony_ci uint8_t *data = NULL; 578bf215546Sopenharmony_ci struct rbug_proto_context_draw_unblock *ret; 579bf215546Sopenharmony_ci 580bf215546Sopenharmony_ci if (!header) 581bf215546Sopenharmony_ci return NULL; 582bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_UNBLOCK) 583bf215546Sopenharmony_ci return NULL; 584bf215546Sopenharmony_ci 585bf215546Sopenharmony_ci pos = 0; 586bf215546Sopenharmony_ci len = header->length * 4; 587bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 588bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 589bf215546Sopenharmony_ci if (!ret) 590bf215546Sopenharmony_ci return NULL; 591bf215546Sopenharmony_ci 592bf215546Sopenharmony_ci ret->header.__message = header; 593bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 594bf215546Sopenharmony_ci 595bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 596bf215546Sopenharmony_ci READ(4, rbug_block_t, unblock); /* unblock */ 597bf215546Sopenharmony_ci 598bf215546Sopenharmony_ci return ret; 599bf215546Sopenharmony_ci} 600bf215546Sopenharmony_ci 601bf215546Sopenharmony_cistruct rbug_proto_context_draw_rule * rbug_demarshal_context_draw_rule(struct rbug_proto_header *header) 602bf215546Sopenharmony_ci{ 603bf215546Sopenharmony_ci uint32_t len = 0; 604bf215546Sopenharmony_ci uint32_t pos = 0; 605bf215546Sopenharmony_ci uint8_t *data = NULL; 606bf215546Sopenharmony_ci struct rbug_proto_context_draw_rule *ret; 607bf215546Sopenharmony_ci 608bf215546Sopenharmony_ci if (!header) 609bf215546Sopenharmony_ci return NULL; 610bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_RULE) 611bf215546Sopenharmony_ci return NULL; 612bf215546Sopenharmony_ci 613bf215546Sopenharmony_ci pos = 0; 614bf215546Sopenharmony_ci len = header->length * 4; 615bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 616bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 617bf215546Sopenharmony_ci if (!ret) 618bf215546Sopenharmony_ci return NULL; 619bf215546Sopenharmony_ci 620bf215546Sopenharmony_ci ret->header.__message = header; 621bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 622bf215546Sopenharmony_ci 623bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 624bf215546Sopenharmony_ci READ(8, rbug_shader_t, vertex); /* vertex */ 625bf215546Sopenharmony_ci READ(8, rbug_shader_t, fragment); /* fragment */ 626bf215546Sopenharmony_ci READ(8, rbug_texture_t, texture); /* texture */ 627bf215546Sopenharmony_ci READ(8, rbug_texture_t, surface); /* surface */ 628bf215546Sopenharmony_ci READ(4, rbug_block_t, block); /* block */ 629bf215546Sopenharmony_ci 630bf215546Sopenharmony_ci return ret; 631bf215546Sopenharmony_ci} 632bf215546Sopenharmony_ci 633bf215546Sopenharmony_cistruct rbug_proto_context_flush * rbug_demarshal_context_flush(struct rbug_proto_header *header) 634bf215546Sopenharmony_ci{ 635bf215546Sopenharmony_ci uint32_t len = 0; 636bf215546Sopenharmony_ci uint32_t pos = 0; 637bf215546Sopenharmony_ci uint8_t *data = NULL; 638bf215546Sopenharmony_ci struct rbug_proto_context_flush *ret; 639bf215546Sopenharmony_ci 640bf215546Sopenharmony_ci if (!header) 641bf215546Sopenharmony_ci return NULL; 642bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_FLUSH) 643bf215546Sopenharmony_ci return NULL; 644bf215546Sopenharmony_ci 645bf215546Sopenharmony_ci pos = 0; 646bf215546Sopenharmony_ci len = header->length * 4; 647bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 648bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 649bf215546Sopenharmony_ci if (!ret) 650bf215546Sopenharmony_ci return NULL; 651bf215546Sopenharmony_ci 652bf215546Sopenharmony_ci ret->header.__message = header; 653bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 654bf215546Sopenharmony_ci 655bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 656bf215546Sopenharmony_ci 657bf215546Sopenharmony_ci return ret; 658bf215546Sopenharmony_ci} 659bf215546Sopenharmony_ci 660bf215546Sopenharmony_cistruct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header) 661bf215546Sopenharmony_ci{ 662bf215546Sopenharmony_ci uint32_t len = 0; 663bf215546Sopenharmony_ci uint32_t pos = 0; 664bf215546Sopenharmony_ci uint8_t *data = NULL; 665bf215546Sopenharmony_ci struct rbug_proto_context_list_reply *ret; 666bf215546Sopenharmony_ci 667bf215546Sopenharmony_ci if (!header) 668bf215546Sopenharmony_ci return NULL; 669bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_LIST_REPLY) 670bf215546Sopenharmony_ci return NULL; 671bf215546Sopenharmony_ci 672bf215546Sopenharmony_ci pos = 0; 673bf215546Sopenharmony_ci len = header->length * 4; 674bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 675bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 676bf215546Sopenharmony_ci if (!ret) 677bf215546Sopenharmony_ci return NULL; 678bf215546Sopenharmony_ci 679bf215546Sopenharmony_ci ret->header.__message = header; 680bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 681bf215546Sopenharmony_ci 682bf215546Sopenharmony_ci READ(4, uint32_t, serial); /* serial */ 683bf215546Sopenharmony_ci READ_ARRAY(8, rbug_context_t, contexts); /* contexts */ 684bf215546Sopenharmony_ci 685bf215546Sopenharmony_ci return ret; 686bf215546Sopenharmony_ci} 687bf215546Sopenharmony_ci 688bf215546Sopenharmony_cistruct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header) 689bf215546Sopenharmony_ci{ 690bf215546Sopenharmony_ci uint32_t len = 0; 691bf215546Sopenharmony_ci uint32_t pos = 0; 692bf215546Sopenharmony_ci uint8_t *data = NULL; 693bf215546Sopenharmony_ci struct rbug_proto_context_info_reply *ret; 694bf215546Sopenharmony_ci 695bf215546Sopenharmony_ci if (!header) 696bf215546Sopenharmony_ci return NULL; 697bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_INFO_REPLY) 698bf215546Sopenharmony_ci return NULL; 699bf215546Sopenharmony_ci 700bf215546Sopenharmony_ci pos = 0; 701bf215546Sopenharmony_ci len = header->length * 4; 702bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 703bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 704bf215546Sopenharmony_ci if (!ret) 705bf215546Sopenharmony_ci return NULL; 706bf215546Sopenharmony_ci 707bf215546Sopenharmony_ci ret->header.__message = header; 708bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 709bf215546Sopenharmony_ci 710bf215546Sopenharmony_ci READ(4, uint32_t, serial); /* serial */ 711bf215546Sopenharmony_ci READ(8, rbug_shader_t, vertex); /* vertex */ 712bf215546Sopenharmony_ci READ(8, rbug_shader_t, fragment); /* fragment */ 713bf215546Sopenharmony_ci READ_ARRAY(8, rbug_texture_t, texs); /* texs */ 714bf215546Sopenharmony_ci READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ 715bf215546Sopenharmony_ci READ(8, rbug_texture_t, zsbuf); /* zsbuf */ 716bf215546Sopenharmony_ci READ(4, rbug_block_t, blocker); /* blocker */ 717bf215546Sopenharmony_ci READ(4, rbug_block_t, blocked); /* blocked */ 718bf215546Sopenharmony_ci 719bf215546Sopenharmony_ci return ret; 720bf215546Sopenharmony_ci} 721bf215546Sopenharmony_ci 722bf215546Sopenharmony_cistruct rbug_proto_context_draw_blocked * rbug_demarshal_context_draw_blocked(struct rbug_proto_header *header) 723bf215546Sopenharmony_ci{ 724bf215546Sopenharmony_ci uint32_t len = 0; 725bf215546Sopenharmony_ci uint32_t pos = 0; 726bf215546Sopenharmony_ci uint8_t *data = NULL; 727bf215546Sopenharmony_ci struct rbug_proto_context_draw_blocked *ret; 728bf215546Sopenharmony_ci 729bf215546Sopenharmony_ci if (!header) 730bf215546Sopenharmony_ci return NULL; 731bf215546Sopenharmony_ci if (header->opcode != (int32_t)RBUG_OP_CONTEXT_DRAW_BLOCKED) 732bf215546Sopenharmony_ci return NULL; 733bf215546Sopenharmony_ci 734bf215546Sopenharmony_ci pos = 0; 735bf215546Sopenharmony_ci len = header->length * 4; 736bf215546Sopenharmony_ci data = (uint8_t*)&header[1]; 737bf215546Sopenharmony_ci ret = MALLOC(sizeof(*ret)); 738bf215546Sopenharmony_ci if (!ret) 739bf215546Sopenharmony_ci return NULL; 740bf215546Sopenharmony_ci 741bf215546Sopenharmony_ci ret->header.__message = header; 742bf215546Sopenharmony_ci ret->header.opcode = header->opcode; 743bf215546Sopenharmony_ci 744bf215546Sopenharmony_ci READ(8, rbug_context_t, context); /* context */ 745bf215546Sopenharmony_ci READ(4, rbug_block_t, block); /* block */ 746bf215546Sopenharmony_ci 747bf215546Sopenharmony_ci return ret; 748bf215546Sopenharmony_ci} 749