* more style cleanup
* backport additional bugfixes from drm version * add logic to detect infinite execution loops * add a semephore to prevent multiple executions on non-thread safe code ( this needs testing ) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42585 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -27,10 +27,8 @@
|
|||||||
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
|
|
||||||
#ifdef ATOM_DEBUG
|
|
||||||
|
|
||||||
#define ATOM_OP_NAMES_CNT 123
|
#define ATOM_OP_NAMES_CNT 123
|
||||||
static char *atom_op_names[ATOM_OP_NAMES_CNT]={
|
const char *atom_op_names[ATOM_OP_NAMES_CNT] = {
|
||||||
"RESERVED", "MOVE_REG", "MOVE_PS", "MOVE_WS", "MOVE_FB", "MOVE_PLL",
|
"RESERVED", "MOVE_REG", "MOVE_PS", "MOVE_WS", "MOVE_FB", "MOVE_PLL",
|
||||||
"MOVE_MC", "AND_REG", "AND_PS", "AND_WS", "AND_FB", "AND_PLL", "AND_MC",
|
"MOVE_MC", "AND_REG", "AND_PS", "AND_WS", "AND_FB", "AND_PLL", "AND_MC",
|
||||||
"OR_REG", "OR_PS", "OR_WS", "OR_FB", "OR_PLL", "OR_MC", "SHIFT_LEFT_REG",
|
"OR_REG", "OR_PS", "OR_WS", "OR_FB", "OR_PLL", "OR_MC", "SHIFT_LEFT_REG",
|
||||||
@@ -56,7 +54,7 @@ static char *atom_op_names[ATOM_OP_NAMES_CNT]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define ATOM_TABLE_NAMES_CNT 74
|
#define ATOM_TABLE_NAMES_CNT 74
|
||||||
static char *atom_table_names[ATOM_TABLE_NAMES_CNT]={
|
const char *atom_table_names[ATOM_TABLE_NAMES_CNT] = {
|
||||||
"ASIC_Init", "GetDisplaySurfaceSize", "ASIC_RegistersInit",
|
"ASIC_Init", "GetDisplaySurfaceSize", "ASIC_RegistersInit",
|
||||||
"VRAM_BlockVenderDetection", "SetClocksRatio", "MemoryControllerInit",
|
"VRAM_BlockVenderDetection", "SetClocksRatio", "MemoryControllerInit",
|
||||||
"GPIO_PinInit", "MemoryParamAdjust", "DVOEncoderControl",
|
"GPIO_PinInit", "MemoryParamAdjust", "DVOEncoderControl",
|
||||||
@@ -85,16 +83,9 @@ static char *atom_table_names[ATOM_TABLE_NAMES_CNT]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define ATOM_IO_NAMES_CNT 5
|
#define ATOM_IO_NAMES_CNT 5
|
||||||
static char *atom_io_names[ATOM_IO_NAMES_CNT]={
|
const char *atom_io_names[ATOM_IO_NAMES_CNT] = {
|
||||||
"MM", "PLL", "MC", "PCIE", "PCIE PORT",
|
"MM", "PLL", "MC", "PCIE", "PCIE PORT",
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define ATOM_OP_NAMES_CNT 0
|
|
||||||
#define ATOM_TABLE_NAMES_CNT 0
|
|
||||||
#define ATOM_IO_NAMES_CNT 0
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -69,10 +69,15 @@ typedef struct {
|
|||||||
uint32 *ps, *ws;
|
uint32 *ps, *ws;
|
||||||
int ps_shift;
|
int ps_shift;
|
||||||
uint16 start;
|
uint16 start;
|
||||||
|
uint16 last_jump;
|
||||||
|
uint16 last_jump_count;
|
||||||
|
bool abort;
|
||||||
} atom_exec_context;
|
} atom_exec_context;
|
||||||
|
|
||||||
int atom_debug = 0;
|
int atom_debug = 0;
|
||||||
void atom_execute_table(atom_context *ctx, int index, uint32 *params);
|
status_t atom_execute_table_locked(atom_context *ctx,
|
||||||
|
int index, uint32 *params);
|
||||||
|
status_t atom_execute_table(atom_context *ctx, int index, uint32 *params);
|
||||||
|
|
||||||
static uint32 atom_arg_mask[8] = {0xFFFFFFFF, 0xFFFF, 0xFFFF00, 0xFFFF0000,
|
static uint32 atom_arg_mask[8] = {0xFFFFFFFF, 0xFFFF, 0xFFFF00, 0xFFFF0000,
|
||||||
0xFF, 0xFF00, 0xFF0000, 0xFF000000};
|
0xFF, 0xFF00, 0xFF0000, 0xFF000000};
|
||||||
@@ -318,6 +323,34 @@ atom_get_src(atom_exec_context *ctx, uint8 attr, int *ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32
|
||||||
|
atom_get_src_direct(atom_exec_context *ctx, uint8_t align, int *ptr)
|
||||||
|
{
|
||||||
|
uint32 val = 0xCDCDCDCD;
|
||||||
|
|
||||||
|
switch (align) {
|
||||||
|
case ATOM_SRC_DWORD:
|
||||||
|
val = U32(*ptr);
|
||||||
|
(*ptr) += 4;
|
||||||
|
break;
|
||||||
|
case ATOM_SRC_WORD0:
|
||||||
|
case ATOM_SRC_WORD8:
|
||||||
|
case ATOM_SRC_WORD16:
|
||||||
|
val = U16(*ptr);
|
||||||
|
(*ptr) += 2;
|
||||||
|
break;
|
||||||
|
case ATOM_SRC_BYTE0:
|
||||||
|
case ATOM_SRC_BYTE8:
|
||||||
|
case ATOM_SRC_BYTE16:
|
||||||
|
case ATOM_SRC_BYTE24:
|
||||||
|
val = U8(*ptr);
|
||||||
|
(*ptr)++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint32
|
static uint32
|
||||||
atom_get_dst(atom_exec_context *ctx, int arg, uint8 attr,
|
atom_get_dst(atom_exec_context *ctx, int arg, uint8 attr,
|
||||||
int *ptr, uint32 *saved, int print)
|
int *ptr, uint32 *saved, int print)
|
||||||
@@ -360,10 +393,12 @@ atom_put_dst(atom_exec_context *ctx, int arg, uint8 attr,
|
|||||||
gctx->card->reg_write(idx, val);
|
gctx->card->reg_write(idx, val);
|
||||||
break;
|
break;
|
||||||
case ATOM_IO_PCI:
|
case ATOM_IO_PCI:
|
||||||
TRACE("%s: PCI registers are not implemented.\n", __func__);
|
TRACE("%s: PCI registers are not implemented.\n",
|
||||||
|
__func__);
|
||||||
return;
|
return;
|
||||||
case ATOM_IO_SYSIO:
|
case ATOM_IO_SYSIO:
|
||||||
TRACE("%s: SYSIO registers are not implemented.\n", __func__);
|
TRACE("%s: SYSIO registers are not implemented.\n",
|
||||||
|
__func__);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
if (!(gctx->io_mode&0x80)) {
|
if (!(gctx->io_mode&0x80)) {
|
||||||
@@ -371,15 +406,18 @@ atom_put_dst(atom_exec_context *ctx, int arg, uint8 attr,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!gctx->iio[gctx->io_mode&0xFF]) {
|
if (!gctx->iio[gctx->io_mode&0xFF]) {
|
||||||
|
TRACE("%s: Undefined indirect IO write method %d\n",
|
||||||
|
__func__, gctx->io_mode & 0x7F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
atom_iio_execute(gctx, gctx->iio[gctx->io_mode&0xFF], idx, val);
|
atom_iio_execute(gctx, gctx->iio[gctx->io_mode&0xFF],
|
||||||
|
idx, val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ATOM_ARG_PS:
|
case ATOM_ARG_PS:
|
||||||
idx = U8(*ptr);
|
idx = U8(*ptr);
|
||||||
(*ptr)++;
|
(*ptr)++;
|
||||||
ctx->ps[idx] = val;
|
ctx->ps[idx] = B_HOST_TO_LENDIAN_INT32(val);
|
||||||
break;
|
break;
|
||||||
case ATOM_ARG_WS:
|
case ATOM_ARG_WS:
|
||||||
idx = U8(*ptr);
|
idx = U8(*ptr);
|
||||||
@@ -406,6 +444,9 @@ atom_put_dst(atom_exec_context *ctx, int arg, uint8 attr,
|
|||||||
case ATOM_WS_ATTRIBUTES:
|
case ATOM_WS_ATTRIBUTES:
|
||||||
gctx->io_attr = val;
|
gctx->io_attr = val;
|
||||||
break;
|
break;
|
||||||
|
case ATOM_WS_REGPTR:
|
||||||
|
gctx->reg_block = val;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ctx->ws[idx] = val;
|
ctx->ws[idx] = val;
|
||||||
}
|
}
|
||||||
@@ -413,18 +454,17 @@ atom_put_dst(atom_exec_context *ctx, int arg, uint8 attr,
|
|||||||
case ATOM_ARG_FB:
|
case ATOM_ARG_FB:
|
||||||
idx = U8(*ptr);
|
idx = U8(*ptr);
|
||||||
(*ptr)++;
|
(*ptr)++;
|
||||||
TRACE("%s: FB access is not implemented.\n", __func__);
|
gctx->scratch[((gctx->fb_base + idx) / 4)] = val;
|
||||||
return;
|
return;
|
||||||
case ATOM_ARG_PLL:
|
case ATOM_ARG_PLL:
|
||||||
idx = U8(*ptr);
|
idx = U8(*ptr);
|
||||||
(*ptr)++;
|
(*ptr)++;
|
||||||
gctx->card->reg_write(PLL_INDEX, idx);
|
gctx->card->pll_write(idx, val);
|
||||||
gctx->card->reg_write(PLL_DATA, val);
|
|
||||||
break;
|
break;
|
||||||
case ATOM_ARG_MC:
|
case ATOM_ARG_MC:
|
||||||
idx = U8(*ptr);
|
idx = U8(*ptr);
|
||||||
(*ptr)++;
|
(*ptr)++;
|
||||||
TRACE("%s: MC registers are not implemented.\n", __func__);
|
gctx->card->mc_write(idx, val);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,9 +515,20 @@ static void
|
|||||||
atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg)
|
atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
{
|
{
|
||||||
int idx = U8((*ptr)++);
|
int idx = U8((*ptr)++);
|
||||||
TRACE("%s: table: %d\n", __func__, idx);
|
status_t result = B_OK;
|
||||||
if (U16(ctx->ctx->cmd_table + 4 + 2 * idx))
|
|
||||||
atom_execute_table(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
|
if (idx < ATOM_TABLE_NAMES_CNT)
|
||||||
|
TRACE("%s: table: %s (%d)\n", __func__, atom_table_names[idx], idx);
|
||||||
|
else
|
||||||
|
TRACE("%s: table: unknown (%d)\n", __func__, idx);
|
||||||
|
|
||||||
|
if (U16(ctx->ctx->cmd_table + 4 + 2 * idx)) {
|
||||||
|
result = atom_execute_table_locked(ctx->ctx,
|
||||||
|
idx, ctx->ps + ctx->ps_shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != B_OK)
|
||||||
|
ctx->abort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -584,24 +635,38 @@ atom_op_jump(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
}
|
}
|
||||||
TRACE("%s: execute jump: %s; target: 0x%04X\n", __func__,
|
TRACE("%s: execute jump: %s; target: 0x%04X\n", __func__,
|
||||||
execute? "yes" : "no", target);
|
execute? "yes" : "no", target);
|
||||||
if (execute)
|
|
||||||
|
if (execute) {
|
||||||
|
if (ctx->last_jump == (ctx->start + target)) {
|
||||||
|
if (ctx->last_jump_count > 128) {
|
||||||
|
TRACE("%s: DANGER! AtomBIOS stuck in infinite loop"
|
||||||
|
" for more then 128 jumps... abort!\n", __func__);
|
||||||
|
ctx->abort = true;
|
||||||
|
} else {
|
||||||
|
ctx->last_jump_count++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ctx->last_jump = ctx->start + target;
|
||||||
|
ctx->last_jump_count = 1;
|
||||||
|
}
|
||||||
*ptr = ctx->start + target;
|
*ptr = ctx->start + target;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
atom_op_mask(atom_exec_context *ctx, int *ptr, int arg)
|
atom_op_mask(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
{
|
{
|
||||||
uint8 attr = U8((*ptr)++);
|
uint8 attr = U8((*ptr)++);
|
||||||
uint32 dst, src1, src2, saved;
|
uint32 dst, mask, src, saved;
|
||||||
int dptr = *ptr;
|
int dptr = *ptr;
|
||||||
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
||||||
src1 = atom_get_src(ctx, attr, ptr);
|
mask = atom_get_src_direct(ctx, ((attr >> 3) & 7), ptr);
|
||||||
src2 = atom_get_src(ctx, attr, ptr);
|
src = atom_get_src(ctx, attr, ptr);
|
||||||
dst &= src1;
|
dst &= mask;
|
||||||
dst |= src2;
|
dst |= src;
|
||||||
TRACE("%s: src: 0x%" B_PRIX32 " mask 0x%" B_PRIX32 " is 0x%" B_PRIX32 "\n",
|
TRACE("%s: src: 0x%" B_PRIX32 " mask 0x%" B_PRIX32 " is 0x%" B_PRIX32 "\n",
|
||||||
__func__, src1, src2, dst);
|
__func__, src, mask, dst);
|
||||||
atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
|
atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +730,8 @@ atom_op_or(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
static void
|
static void
|
||||||
atom_op_postcard(atom_exec_context *ctx, int *ptr, int arg)
|
atom_op_postcard(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
{
|
{
|
||||||
TRACE("%s: unimplemented!\n", __func__);
|
uint8 val = U8((*ptr)++);
|
||||||
|
TRACE("%s: POST card output: 0x%" B_PRIX8 "\n", __func__, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -720,6 +786,10 @@ atom_op_setport(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
switch(arg) {
|
switch(arg) {
|
||||||
case ATOM_PORT_ATI:
|
case ATOM_PORT_ATI:
|
||||||
port = U16(*ptr);
|
port = U16(*ptr);
|
||||||
|
if (port < ATOM_IO_NAMES_CNT) {
|
||||||
|
TRACE("%s: port: %d (%s)\n", __func__,
|
||||||
|
port, atom_io_names[port]);
|
||||||
|
} else
|
||||||
TRACE("%s: port: %d\n", __func__, port);
|
TRACE("%s: port: %d\n", __func__, port);
|
||||||
if (!port)
|
if (!port)
|
||||||
ctx->ctx->io_mode = ATOM_IO_MM;
|
ctx->ctx->io_mode = ATOM_IO_MM;
|
||||||
@@ -747,8 +817,7 @@ atom_op_setregblock(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void atom_op_shift_left(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
atom_op_shl(atom_exec_context *ctx, int *ptr, int arg)
|
|
||||||
{
|
{
|
||||||
uint8 attr = U8((*ptr)++), shift;
|
uint8 attr = U8((*ptr)++), shift;
|
||||||
uint32 saved, dst;
|
uint32 saved, dst;
|
||||||
@@ -756,7 +825,7 @@ atom_op_shl(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
attr &= 0x38;
|
attr &= 0x38;
|
||||||
attr |= atom_def_dst[attr >> 3] << 6;
|
attr |= atom_def_dst[attr >> 3] << 6;
|
||||||
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
||||||
shift = U8((*ptr)++);
|
shift = atom_get_src_direct(ctx, ATOM_SRC_BYTE0, ptr);
|
||||||
#ifdef ATOM_TRACE
|
#ifdef ATOM_TRACE
|
||||||
TRACE("%s: 0x%" B_PRIX32 " << %" B_PRId8 " is 0X%" B_PRIX32 "\n",
|
TRACE("%s: 0x%" B_PRIX32 " << %" B_PRId8 " is 0X%" B_PRIX32 "\n",
|
||||||
__func__, dst, shift, dst << shift);
|
__func__, dst, shift, dst << shift);
|
||||||
@@ -766,8 +835,7 @@ atom_op_shl(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void atom_op_shift_right(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
atom_op_shr(atom_exec_context *ctx, int *ptr, int arg)
|
|
||||||
{
|
{
|
||||||
uint8 attr = U8((*ptr)++), shift;
|
uint8 attr = U8((*ptr)++), shift;
|
||||||
uint32 saved, dst;
|
uint32 saved, dst;
|
||||||
@@ -775,16 +843,58 @@ atom_op_shr(atom_exec_context *ctx, int *ptr, int arg)
|
|||||||
attr &= 0x38;
|
attr &= 0x38;
|
||||||
attr |= atom_def_dst[attr >> 3] << 6;
|
attr |= atom_def_dst[attr >> 3] << 6;
|
||||||
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
||||||
shift = U8((*ptr)++);
|
shift = atom_get_src_direct(ctx, ATOM_SRC_BYTE0, ptr);
|
||||||
#ifdef ATOM_TRACE
|
#ifdef ATOM_TRACE
|
||||||
TRACE("%s: 0x%" B_PRIX32 " >> %" B_PRId8 " is 0X%" B_PRIX32 "\n",
|
TRACE("%s: 0x%" B_PRIX32 " >> %" B_PRId8 " is 0X%" B_PRIX32 "\n",
|
||||||
__func__, dst, shift, dst >> shift);
|
__func__, dst, shift, dst << shift);
|
||||||
#endif
|
#endif
|
||||||
dst >>= shift;
|
dst >>= shift;
|
||||||
atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
|
atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void atom_op_shl(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
|
{
|
||||||
|
uint8 attr = U8((*ptr)++), shift;
|
||||||
|
uint32 saved, dst;
|
||||||
|
int dptr = *ptr;
|
||||||
|
uint32 dst_align = atom_dst_to_src[(attr >> 3) & 7][(attr >> 6) & 3];
|
||||||
|
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
||||||
|
/* op needs to full dst value */
|
||||||
|
dst = saved;
|
||||||
|
shift = atom_get_src(ctx, attr, ptr);
|
||||||
|
#ifdef ATOM_TRACE
|
||||||
|
TRACE("%s: 0x%" B_PRIX32 " << %" B_PRId8 " is 0X%" B_PRIX32 "\n",
|
||||||
|
__func__, dst, shift, dst << shift);
|
||||||
|
#endif
|
||||||
|
dst <<= shift;
|
||||||
|
dst &= atom_arg_mask[dst_align];
|
||||||
|
dst >>= atom_arg_shift[dst_align];
|
||||||
|
atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void atom_op_shr(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
|
{
|
||||||
|
uint8 attr = U8((*ptr)++), shift;
|
||||||
|
uint32 saved, dst;
|
||||||
|
int dptr = *ptr;
|
||||||
|
uint32 dst_align = atom_dst_to_src[(attr >> 3) & 7][(attr >> 6) & 3];
|
||||||
|
dst = atom_get_dst(ctx, arg, attr, ptr, &saved, 1);
|
||||||
|
/* op needs to full dst value */
|
||||||
|
dst = saved;
|
||||||
|
shift = atom_get_src(ctx, attr, ptr);
|
||||||
|
#ifdef ATOM_TRACE
|
||||||
|
TRACE("%s: 0x%" B_PRIX32 " >> %" B_PRId8 " is 0X%" B_PRIX32 "\n",
|
||||||
|
__func__, dst, shift, dst << shift);
|
||||||
|
#endif
|
||||||
|
dst >>= shift;
|
||||||
|
dst &= atom_arg_mask[dst_align];
|
||||||
|
dst >>= atom_arg_shift[dst_align];
|
||||||
|
atom_put_dst(ctx, arg, attr, &dptr, dst, saved);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
atom_op_sub(atom_exec_context *ctx, int *ptr, int arg)
|
atom_op_sub(atom_exec_context *ctx, int *ptr, int arg)
|
||||||
{
|
{
|
||||||
@@ -888,18 +998,18 @@ static struct {
|
|||||||
{ atom_op_or, ATOM_ARG_FB },
|
{ atom_op_or, ATOM_ARG_FB },
|
||||||
{ atom_op_or, ATOM_ARG_PLL },
|
{ atom_op_or, ATOM_ARG_PLL },
|
||||||
{ atom_op_or, ATOM_ARG_MC },
|
{ atom_op_or, ATOM_ARG_MC },
|
||||||
{ atom_op_shl, ATOM_ARG_REG },
|
{ atom_op_shift_left, ATOM_ARG_REG },
|
||||||
{ atom_op_shl, ATOM_ARG_PS },
|
{ atom_op_shift_left, ATOM_ARG_PS },
|
||||||
{ atom_op_shl, ATOM_ARG_WS },
|
{ atom_op_shift_left, ATOM_ARG_WS },
|
||||||
{ atom_op_shl, ATOM_ARG_FB },
|
{ atom_op_shift_left, ATOM_ARG_FB },
|
||||||
{ atom_op_shl, ATOM_ARG_PLL },
|
{ atom_op_shift_left, ATOM_ARG_PLL },
|
||||||
{ atom_op_shl, ATOM_ARG_MC },
|
{ atom_op_shift_left, ATOM_ARG_MC },
|
||||||
{ atom_op_shr, ATOM_ARG_REG },
|
{ atom_op_shift_right, ATOM_ARG_REG },
|
||||||
{ atom_op_shr, ATOM_ARG_PS },
|
{ atom_op_shift_right, ATOM_ARG_PS },
|
||||||
{ atom_op_shr, ATOM_ARG_WS },
|
{ atom_op_shift_right, ATOM_ARG_WS },
|
||||||
{ atom_op_shr, ATOM_ARG_FB },
|
{ atom_op_shift_right, ATOM_ARG_FB },
|
||||||
{ atom_op_shr, ATOM_ARG_PLL },
|
{ atom_op_shift_right, ATOM_ARG_PLL },
|
||||||
{ atom_op_shr, ATOM_ARG_MC },
|
{ atom_op_shift_right, ATOM_ARG_MC },
|
||||||
{ atom_op_mul, ATOM_ARG_REG },
|
{ atom_op_mul, ATOM_ARG_REG },
|
||||||
{ atom_op_mul, ATOM_ARG_PS },
|
{ atom_op_mul, ATOM_ARG_PS },
|
||||||
{ atom_op_mul, ATOM_ARG_WS },
|
{ atom_op_mul, ATOM_ARG_WS },
|
||||||
@@ -994,8 +1104,8 @@ static struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void
|
status_t
|
||||||
atom_execute_table(atom_context *ctx, int index, uint32 *params)
|
atom_execute_table_locked(atom_context *ctx, int index, uint32 * params)
|
||||||
{
|
{
|
||||||
int base = CU16(ctx->cmd_table + 4 + 2 * index);
|
int base = CU16(ctx->cmd_table + 4 + 2 * index);
|
||||||
int len, ws, ps, ptr;
|
int len, ws, ps, ptr;
|
||||||
@@ -1003,19 +1113,20 @@ atom_execute_table(atom_context *ctx, int index, uint32 *params)
|
|||||||
atom_exec_context ectx;
|
atom_exec_context ectx;
|
||||||
|
|
||||||
if (!base)
|
if (!base)
|
||||||
return;
|
return B_ERROR;
|
||||||
|
|
||||||
len = CU16(base + ATOM_CT_SIZE_PTR);
|
len = CU16(base + ATOM_CT_SIZE_PTR);
|
||||||
ws = CU8(base + ATOM_CT_WS_PTR);
|
ws = CU8(base + ATOM_CT_WS_PTR);
|
||||||
ps = CU8(base + ATOM_CT_PS_PTR) & ATOM_CT_PS_MASK;
|
ps = CU8(base + ATOM_CT_PS_PTR) & ATOM_CT_PS_MASK;
|
||||||
ptr = base + ATOM_CT_CODE_PTR;
|
ptr = base + ATOM_CT_CODE_PTR;
|
||||||
|
|
||||||
/* reset reg block */
|
|
||||||
ctx->reg_block = 0;
|
|
||||||
ectx.ctx = ctx;
|
ectx.ctx = ctx;
|
||||||
ectx.ps_shift = ps / 4;
|
ectx.ps_shift = ps / 4;
|
||||||
ectx.start = base;
|
ectx.start = base;
|
||||||
ectx.ps = params;
|
ectx.ps = params;
|
||||||
|
ectx.abort = false;
|
||||||
|
ectx.last_jump = 0;
|
||||||
|
ectx.last_jump_count = 0;
|
||||||
if (ws)
|
if (ws)
|
||||||
ectx.ws = (uint32*)malloc(4 * ws);
|
ectx.ws = (uint32*)malloc(4 * ws);
|
||||||
else
|
else
|
||||||
@@ -1024,6 +1135,18 @@ atom_execute_table(atom_context *ctx, int index, uint32 *params)
|
|||||||
debug_depth++;
|
debug_depth++;
|
||||||
while (1) {
|
while (1) {
|
||||||
op = CU8(ptr++);
|
op = CU8(ptr++);
|
||||||
|
if (op < ATOM_OP_NAMES_CNT) {
|
||||||
|
TRACE("%s: %s (0x%" B_PRIX16 ")\n", __func__,
|
||||||
|
atom_op_names[op], ptr - 1);
|
||||||
|
} else
|
||||||
|
TRACE("%s: unknown (0x%" B_PRIX16 ")\n", __func__, ptr - 1);
|
||||||
|
|
||||||
|
if (ectx.abort == true) {
|
||||||
|
TRACE("AtomBios parser was aborted executing (0x%" B_PRIX16 ")\n",
|
||||||
|
ptr - 1);
|
||||||
|
free(ectx.ws);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (op < ATOM_OP_CNT && op > 0)
|
if (op < ATOM_OP_CNT && op > 0)
|
||||||
opcode_table[op].func(&ectx, &ptr, opcode_table[op].arg);
|
opcode_table[op].func(&ectx, &ptr, opcode_table[op].arg);
|
||||||
@@ -1034,10 +1157,30 @@ atom_execute_table(atom_context *ctx, int index, uint32 *params)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
debug_depth--;
|
debug_depth--;
|
||||||
TRACE("<<\n");
|
|
||||||
|
|
||||||
if (ws)
|
|
||||||
free(ectx.ws);
|
free(ectx.ws);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
atom_execute_table(atom_context *ctx, int index, uint32 *params)
|
||||||
|
{
|
||||||
|
if (acquire_sem_etc(ctx->exec_sem, 1, B_RELATIVE_TIMEOUT, 5000000)
|
||||||
|
!= B_NO_ERROR) {
|
||||||
|
TRACE("%s: Timeout to obtain semaphore!\n", __func__);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
/* reset reg block */
|
||||||
|
ctx->reg_block = 0;
|
||||||
|
/* reset fb window */
|
||||||
|
ctx->fb_base = 0;
|
||||||
|
/* reset io mode */
|
||||||
|
ctx->io_mode = ATOM_IO_MM;
|
||||||
|
status_t result = atom_execute_table_locked(ctx, index, params);
|
||||||
|
|
||||||
|
release_sem(ctx->exec_sem);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
#include <ByteOrder.h>
|
||||||
|
|
||||||
|
|
||||||
struct card_info {
|
struct card_info {
|
||||||
@@ -131,6 +132,7 @@ typedef struct atom_context_s {
|
|||||||
uint32 cmd_table, data_table;
|
uint32 cmd_table, data_table;
|
||||||
uint16 *iio;
|
uint16 *iio;
|
||||||
|
|
||||||
|
sem_id exec_sem;
|
||||||
uint16 data_block;
|
uint16 data_block;
|
||||||
uint32 fb_base;
|
uint32 fb_base;
|
||||||
uint32 divmul[2];
|
uint32 divmul[2];
|
||||||
@@ -145,7 +147,7 @@ typedef struct atom_context_s {
|
|||||||
extern int atom_debug;
|
extern int atom_debug;
|
||||||
|
|
||||||
atom_context *atom_parse(card_info *, void *);
|
atom_context *atom_parse(card_info *, void *);
|
||||||
void atom_execute_table(atom_context *, int, uint32 *);
|
status_t atom_execute_table(atom_context *, int, uint32 *);
|
||||||
int atom_asic_init(atom_context *);
|
int atom_asic_init(atom_context *);
|
||||||
void atom_destroy(atom_context *);
|
void atom_destroy(atom_context *);
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,13 @@ radeon_init_bios(uint8* bios)
|
|||||||
atom_asic_init(gAtomContext);
|
atom_asic_init(gAtomContext);
|
||||||
// Post card
|
// Post card
|
||||||
|
|
||||||
// mutex_init(&rdev->mode_info.atom_context->mutex);
|
if ((gAtomContext->exec_sem = create_sem(1, "AtomBIOS_exec"))
|
||||||
|
< B_NO_ERROR) {
|
||||||
|
TRACE("%s: couldn't create semaphore for AtomBIOS exec thread!\n",
|
||||||
|
__func__);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
radeon_bios_init_scratch();
|
radeon_bios_init_scratch();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user