brw_aub.c File Reference

Include dependency graph for brw_aub.c:

Go to the source code of this file.

Data Structures

struct  brw_aubfile
struct  aub_file_header
struct  aub_block_header
struct  aub_dump_bmp

Defines

#define AUB_FILE_HEADER   0xe085000b
#define AUB_BLOCK_HEADER   0xe0c10003
#define AUB_DUMP_BMP   0xe09e0004
#define PGETBL_CTL   0x2020
#define PGETBL_ENABLED   0x1
#define NR_GTT_ENTRIES   65536
#define FAIL

Enumerations

enum  bh_operation {
  BH_COMMENT, BH_DATA_WRITE, BH_COMMAND_WRITE, BH_MMI0_WRITE32,
  BH_END_SCENE, BH_CONFIG_MEMORY_MAP, BH_MAX_OPERATION
}
enum  command_write_type {
  CW_HWB_RING = 1, CW_PRIMARY_RING_A, CW_PRIMARY_RING_B, CW_PRIMARY_RING_C,
  CW_MAX_TYPE
}
enum  memory_map_type { MM_DEFAULT, MM_DYNAMIC, MM_MAX_TYPE }
enum  address_space { ADDR_GTT, ADDR_LOCAL, ADDR_MAIN, ADDR_MAX }

Functions

static void init_aubfile (FILE *aub_file)
static void init_aub_gtt (struct brw_aubfile *aubfile, unsigned start_offset, unsigned size)
static void write_block_header (FILE *aub_file, struct aub_block_header *bh, const unsigned *data, unsigned sz)
static void write_dump_bmp (FILE *aub_file, struct aub_dump_bmp *db)
void brw_aub_gtt_data (struct brw_aubfile *aubfile, unsigned offset, const void *data, unsigned sz, unsigned type, unsigned state_type)
void brw_aub_gtt_cmds (struct brw_aubfile *aubfile, unsigned offset, const void *data, unsigned sz)
void brw_aub_dump_bmp (struct brw_aubfile *aubfile, struct pipe_surface *surface, unsigned gtt_offset)
struct brw_aubfilebrw_aubfile_create (void)
void brw_aub_destroy (struct brw_aubfile *aubfile)

Variables

char * __progname


Define Documentation

#define AUB_BLOCK_HEADER   0xe0c10003

Definition at line 126 of file brw_aub.c.

#define AUB_DUMP_BMP   0xe09e0004

Definition at line 127 of file brw_aub.c.

#define AUB_FILE_HEADER   0xe085000b

Definition at line 125 of file brw_aub.c.

#define FAIL

Value:

do {                                                                                    \
   fprintf(stderr, "failed to write aub data at %s/%d\n", __FUNCTION__, __LINE__);      \
   exit(1);                                                                             \
} while (0)

Definition at line 136 of file brw_aub.c.

#define NR_GTT_ENTRIES   65536

Definition at line 134 of file brw_aub.c.

#define PGETBL_CTL   0x2020

Definition at line 131 of file brw_aub.c.

#define PGETBL_ENABLED   0x1

Definition at line 132 of file brw_aub.c.


Enumeration Type Documentation

enum address_space

Enumerator:
ADDR_GTT 
ADDR_LOCAL 
ADDR_MAIN 
ADDR_MAX 

Definition at line 117 of file brw_aub.c.

00117                    {
00118    ADDR_GTT,
00119    ADDR_LOCAL,
00120    ADDR_MAIN,
00121    ADDR_MAX
00122 };

enum bh_operation

Enumerator:
BH_COMMENT 
BH_DATA_WRITE 
BH_COMMAND_WRITE 
BH_MMI0_WRITE32 
BH_END_SCENE 
BH_CONFIG_MEMORY_MAP 
BH_MAX_OPERATION 

Definition at line 93 of file brw_aub.c.

00093                   {
00094    BH_COMMENT,
00095    BH_DATA_WRITE,
00096    BH_COMMAND_WRITE,
00097    BH_MMI0_WRITE32,
00098    BH_END_SCENE,
00099    BH_CONFIG_MEMORY_MAP,
00100    BH_MAX_OPERATION
00101 };

enum command_write_type

Enumerator:
CW_HWB_RING 
CW_PRIMARY_RING_A 
CW_PRIMARY_RING_B 
CW_PRIMARY_RING_C 
CW_MAX_TYPE 

Definition at line 103 of file brw_aub.c.

00103                         {
00104    CW_HWB_RING = 1,
00105    CW_PRIMARY_RING_A,
00106    CW_PRIMARY_RING_B,           /* XXX - disagreement with listaub! */
00107    CW_PRIMARY_RING_C,
00108    CW_MAX_TYPE
00109 };

enum memory_map_type

Enumerator:
MM_DEFAULT 
MM_DYNAMIC 
MM_MAX_TYPE 

Definition at line 111 of file brw_aub.c.

00111                      {
00112    MM_DEFAULT,
00113    MM_DYNAMIC,
00114    MM_MAX_TYPE
00115 };


Function Documentation

void brw_aub_destroy ( struct brw_aubfile aubfile  ) 

Definition at line 393 of file brw_aub.c.

References brw_aubfile::file, and FREE.

00394 {
00395    fclose(aubfile->file);
00396    FREE(aubfile);
00397 }

void brw_aub_dump_bmp ( struct brw_aubfile aubfile,
struct pipe_surface surface,
unsigned  gtt_offset 
)

Definition at line 318 of file brw_aub.c.

References aub_dump_bmp::addr, assert, AUB_DUMP_BMP, pipe_surface::block, aub_dump_bmp::bpp, brw_aubfile::file, aub_dump_bmp::format, pipe_surface::height, pipe_format_block::height, aub_dump_bmp::instruction_type, aub_dump_bmp::pitch, pipe_format_block::size, pipe_surface::stride, aub_dump_bmp::unknown, pipe_surface::width, pipe_format_block::width, write_dump_bmp(), aub_dump_bmp::xmin, aub_dump_bmp::xsize, aub_dump_bmp::ymin, and aub_dump_bmp::ysize.

00321 {
00322    struct aub_dump_bmp db;
00323    unsigned format;
00324 
00325    assert(surface->block.width == 1);
00326    assert(surface->block.height == 1);
00327    
00328    if (surface->block.size == 4)
00329       format = 0x7;
00330    else
00331       format = 0x3;
00332 
00333    db.instruction_type = AUB_DUMP_BMP;
00334    db.xmin = 0;
00335    db.ymin = 0;
00336    db.format = format;
00337    db.bpp = surface->block.size * 8;
00338    db.pitch = surface->stride/surface->block.size;
00339    db.xsize = surface->width;
00340    db.ysize = surface->height;
00341    db.addr = gtt_offset;
00342    db.unknown = /* surface->tiled ? 0x4 : */ 0x0;
00343 
00344    write_dump_bmp(aubfile->file, &db);
00345 }

void brw_aub_gtt_cmds ( struct brw_aubfile aubfile,
unsigned  offset,
const void *  data,
unsigned  sz 
)

Definition at line 295 of file brw_aub.c.

References ADDR_GTT, aub_block_header::address, aub_block_header::address_space, AUB_BLOCK_HEADER, BH_COMMAND_WRITE, CW_PRIMARY_RING_A, brw_aubfile::file, aub_block_header::general_state_type, aub_block_header::instruction_type, aub_block_header::length, aub_block_header::operation, aub_block_header::pad0, aub_block_header::pad1, aub_block_header::surface_state_type, aub_block_header::type, and write_block_header().

00299 {
00300    struct aub_block_header bh;   
00301    unsigned type = CW_PRIMARY_RING_A;
00302    
00303 
00304    bh.instruction_type = AUB_BLOCK_HEADER;
00305    bh.operation = BH_COMMAND_WRITE;
00306    bh.type = type;
00307    bh.address_space = ADDR_GTT;
00308    bh.pad0 = 0;
00309    bh.general_state_type = 0;
00310    bh.surface_state_type = 0;
00311    bh.pad1 = 0;
00312    bh.address = offset;
00313    bh.length = sz;
00314 
00315    write_block_header(aubfile->file, &bh, data, sz);
00316 }

void brw_aub_gtt_data ( struct brw_aubfile aubfile,
unsigned  offset,
const void *  data,
unsigned  sz,
unsigned  type,
unsigned  state_type 
)

Definition at line 262 of file brw_aub.c.

References ADDR_GTT, aub_block_header::address, aub_block_header::address_space, AUB_BLOCK_HEADER, BH_DATA_WRITE, DW_GENERAL_STATE, brw_aubfile::file, aub_block_header::general_state_type, aub_block_header::instruction_type, aub_block_header::length, aub_block_header::operation, aub_block_header::pad0, aub_block_header::pad1, aub_block_header::surface_state_type, aub_block_header::type, and write_block_header().

00268 {
00269    struct aub_block_header bh;
00270 
00271    bh.instruction_type = AUB_BLOCK_HEADER;
00272    bh.operation = BH_DATA_WRITE;
00273    bh.type = type;
00274    bh.address_space = ADDR_GTT;
00275    bh.pad0 = 0;
00276 
00277    if (type == DW_GENERAL_STATE) {
00278       bh.general_state_type = state_type;
00279       bh.surface_state_type = 0;
00280    }
00281    else {
00282       bh.general_state_type = 0;
00283       bh.surface_state_type = state_type;
00284    }
00285 
00286    bh.pad1 = 0;
00287    bh.address = offset;
00288    bh.length = sz;
00289 
00290    write_block_header(aubfile->file, &bh, data, sz);
00291 }

struct brw_aubfile* brw_aubfile_create ( void   )  [read]

Definition at line 349 of file brw_aub.c.

References __progname, AUB_BUF_SIZE, AUB_BUF_START, CALLOC_STRUCT, debug_printf(), brw_aubfile::file, init_aub_gtt(), init_aubfile(), brw_aubfile::next_free_page, and NR_GTT_ENTRIES.

00350 {
00351    struct brw_aubfile *aubfile = CALLOC_STRUCT(brw_aubfile);
00352    char filename[80];
00353    int val;
00354    static int i = 0;
00355 
00356    i++;
00357 
00358    if (getenv("INTEL_AUBFILE")) {
00359       val = snprintf(filename, sizeof(filename), "%s%d.aub", getenv("INTEL_AUBFILE"), i%4);
00360       debug_printf("--> Aub file: %s\n", filename);
00361       aubfile->file = fopen(filename, "w");
00362    }
00363    else {
00364       val = snprintf(filename, sizeof(filename), "%s.aub", __progname);
00365       if (val < 0 || val > sizeof(filename)) 
00366          strcpy(filename, "default.aub");   
00367    
00368       debug_printf("--> Aub file: %s\n", filename);
00369       aubfile->file = fopen(filename, "w");
00370    }
00371 
00372    if (!aubfile->file) {
00373       debug_printf("couldn't open aubfile\n");
00374       exit(1);
00375    }
00376 
00377    init_aubfile(aubfile->file);
00378 
00379    /* The GTT is located starting address zero in main memory.  Pages
00380     * to populate the gtt start after this point.
00381     */
00382    aubfile->next_free_page = (NR_GTT_ENTRIES * 4 + 4095) & ~4095;
00383 
00384    /* More or less correspond with all the agp regions mapped by the
00385     * driver:
00386     */
00387    init_aub_gtt(aubfile, 0, 4096*4);
00388    init_aub_gtt(aubfile, AUB_BUF_START, AUB_BUF_SIZE);
00389 
00390    return aubfile;
00391 }

static void init_aub_gtt ( struct brw_aubfile aubfile,
unsigned  start_offset,
unsigned  size 
) [static]

Definition at line 198 of file brw_aub.c.

References ADDR_MAIN, aub_block_header::address, aub_block_header::address_space, assert, AUB_BLOCK_HEADER, BH_DATA_WRITE, FAIL, brw_aubfile::file, aub_block_header::general_state_type, aub_block_header::instruction_type, aub_block_header::length, brw_aubfile::next_free_page, NR_GTT_ENTRIES, aub_block_header::operation, aub_block_header::surface_state_type, and aub_block_header::type.

00201 {
00202    FILE *aub_file = aubfile->file;
00203    struct aub_block_header bh;
00204    unsigned int i;
00205 
00206    assert(start_offset + size < NR_GTT_ENTRIES * 4096);
00207 
00208 
00209    memset(&bh, 0, sizeof(bh));
00210    
00211    bh.instruction_type = AUB_BLOCK_HEADER;
00212    bh.operation = BH_DATA_WRITE;
00213    bh.type = 0x0;
00214    bh.address_space = ADDR_MAIN;
00215    bh.general_state_type = 0x0;
00216    bh.surface_state_type = 0x0;
00217    bh.address =  start_offset / 4096 * 4;
00218    bh.length = size / 4096 * 4;
00219 
00220    if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0) 
00221       FAIL;
00222 
00223    for (i = 0; i < size / 4096; i++) {
00224       unsigned data = aubfile->next_free_page | 1;
00225 
00226       aubfile->next_free_page += 4096;
00227 
00228       if (fwrite(&data, sizeof(data), 1, aub_file) < 0) 
00229          FAIL;
00230    }
00231 
00232 }

static void init_aubfile ( FILE *  aub_file  )  [static]

Definition at line 145 of file brw_aub.c.

References __progname, ADDR_GTT, aub_block_header::address, aub_block_header::address_space, aub_file_header::application, AUB_BLOCK_HEADER, AUB_FILE_HEADER, BH_MMI0_WRITE32, aub_file_header::comment_length, aub_file_header::day, FAIL, aub_block_header::general_state_type, aub_file_header::hour, aub_block_header::instruction_type, aub_file_header::instruction_type, aub_block_header::length, aub_file_header::major, aub_file_header::minor, aub_file_header::minute, aub_file_header::month, aub_block_header::operation, PGETBL_CTL, PGETBL_ENABLED, aub_file_header::second, aub_block_header::surface_state_type, aub_file_header::timezone, aub_block_header::type, and aub_file_header::year.

00146 {   
00147    struct aub_file_header fh;
00148    struct aub_block_header bh;
00149    unsigned int data;
00150 
00151    static int nr;
00152    
00153    nr++;
00154 
00155    /* Emit the aub header:
00156     */
00157    memset(&fh, 0, sizeof(fh));
00158 
00159    fh.instruction_type = AUB_FILE_HEADER;
00160    fh.minor = 0x0;
00161    fh.major = 0x7;
00162    memcpy(fh.application, __progname, sizeof(fh.application));
00163    fh.day = (nr>>24) & 0xff;
00164    fh.month = 0x0;
00165    fh.year = 0x0;
00166    fh.timezone = 0x0;
00167    fh.second = nr & 0xff;
00168    fh.minute = (nr>>8) & 0xff;
00169    fh.hour = (nr>>16) & 0xff;
00170    fh.comment_length = 0x0;   
00171 
00172    if (fwrite(&fh, sizeof(fh), 1, aub_file) < 0) 
00173       FAIL;
00174          
00175    /* Setup the GTT starting at main memory address zero (!):
00176     */
00177    memset(&bh, 0, sizeof(bh));
00178    
00179    bh.instruction_type = AUB_BLOCK_HEADER;
00180    bh.operation = BH_MMI0_WRITE32;
00181    bh.type = 0x0;
00182    bh.address_space = ADDR_GTT; /* ??? */
00183    bh.general_state_type = 0x0;
00184    bh.surface_state_type = 0x0;
00185    bh.address = PGETBL_CTL;
00186    bh.length = 0x4;
00187 
00188    if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0) 
00189       FAIL;
00190 
00191    data = 0x0 | PGETBL_ENABLED;
00192 
00193    if (fwrite(&data, sizeof(data), 1, aub_file) < 0) 
00194       FAIL;
00195 }

static void write_block_header ( FILE *  aub_file,
struct aub_block_header bh,
const unsigned *  data,
unsigned  sz 
) [static]

Definition at line 234 of file brw_aub.c.

References FAIL.

00238 {
00239    sz = (sz + 3) & ~3;
00240 
00241    if (fwrite(bh, sizeof(*bh), 1, aub_file) < 0) 
00242       FAIL;
00243 
00244    if (fwrite(data, sz, 1, aub_file) < 0) 
00245       FAIL;
00246 
00247    fflush(aub_file);
00248 }

static void write_dump_bmp ( FILE *  aub_file,
struct aub_dump_bmp db 
) [static]

Definition at line 251 of file brw_aub.c.

References FAIL.

00253 {
00254    if (fwrite(db, sizeof(*db), 1, aub_file) < 0) 
00255       FAIL;
00256 
00257    fflush(aub_file);
00258 }


Variable Documentation

char* __progname


Generated on Tue Sep 29 06:25:49 2009 for Gallium3D by  doxygen 1.5.4