From ed88c48badbd51ecfdb4cbf7a9770934ca891709 Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <kallisti5@unixzen.com>
Date: Fri, 4 Mar 2016 17:58:32 -0600
Subject: [PATCH] radeon_hd: Add updated / missing atombios opcodes
* Newer cards introduce two new opcodes mul32 and div32
* Add completely missing processds opcode
---
.../accelerants/radeon_hd/atombios/atom.cpp | 63 +++++++++++++++++++++-
src/add-ons/accelerants/radeon_hd/atombios/atom.h | 2 +-
2 files changed, 63 insertions(+), 2 deletions(-)
diff --git a/src/add-ons/accelerants/radeon_hd/atombios/atom.cpp b/src/add-ons/accelerants/radeon_hd/atombios/atom.cpp
index 2afcd26..376b721 100644
a
|
b
|
|
1 | 1 | /* |
2 | | * Copyright 2008 Advanced Micro Devices, Inc. |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
3 | 3 | * |
4 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | 5 | * copy of this software and associated documentation files (the "Software"), |
… |
… |
atom_op_div(atom_exec_context *ctx, int *ptr, int arg)
|
622 | 622 | |
623 | 623 | |
624 | 624 | static void |
| 625 | atom_op_div32(atom_exec_context *ctx, int *ptr, int arg) |
| 626 | { |
| 627 | uint64 val64; |
| 628 | uint8 attr = U8((*ptr)++); |
| 629 | uint32 dst, src; |
| 630 | dst = atom_get_dst(ctx, arg, attr, ptr, NULL, 1); |
| 631 | src = atom_get_src(ctx, attr, ptr); |
| 632 | if (src != 0) { |
| 633 | val64 = dst; |
| 634 | val64 |= ((uint64)ctx->ctx->divmul[1]) << 32; |
| 635 | val64 /= src; |
| 636 | // Lower and upper 32 bits |
| 637 | ctx->ctx->divmul[0] = (uint32)val64; |
| 638 | ctx->ctx->divmul[1] = (uint32)(((val64) >> 16) >> 16); |
| 639 | } else { |
| 640 | ctx->ctx->divmul[0] = 0; |
| 641 | ctx->ctx->divmul[1] = 0; |
| 642 | } |
| 643 | #ifdef ATOM_TRACE |
| 644 | TRACE("%s: 0x%" B_PRIX32 " / 0x%" B_PRIX32 " is" |
| 645 | " 0x%" B_PRIX32 " + 0x%" B_PRIX32 "\n", __func__, dst, src, |
| 646 | ctx->ctx->divmul[0], ctx->ctx->divmul[1]); |
| 647 | #endif |
| 648 | } |
| 649 | |
| 650 | |
| 651 | static void |
625 | 652 | atom_op_eot(atom_exec_context *ctx, int *ptr, int arg) |
626 | 653 | { |
627 | 654 | /* functionally, a nop */ |
… |
… |
atom_op_mul(atom_exec_context *ctx, int *ptr, int arg)
|
730 | 757 | |
731 | 758 | |
732 | 759 | static void |
| 760 | atom_op_mul32(atom_exec_context *ctx, int *ptr, int arg) |
| 761 | { |
| 762 | uint64 val64; |
| 763 | uint8 attr = U8((*ptr)++); |
| 764 | uint32 dst, src; |
| 765 | dst = atom_get_dst(ctx, arg, attr, ptr, NULL, 1); |
| 766 | src = atom_get_src(ctx, attr, ptr); |
| 767 | val64 = (uint64)dst * (uint64)src; |
| 768 | // Lower and upper 32 bits |
| 769 | ctx->ctx->divmul[0] = (uint32)val64; |
| 770 | ctx->ctx->divmul[1] = (uint32)(((val64) >> 16) >> 16); |
| 771 | #ifdef ATOM_TRACE |
| 772 | TRACE("%s: 0x%" B_PRIX32 " * 0x%" B_PRIX32 " is" |
| 773 | " 0x%" B_PRIX32 " + 0x%" B_PRIX32 "\n", __func__, dst, src, |
| 774 | ctx->ctx->divmul[0], ctx->ctx->divmul[1]); |
| 775 | #endif |
| 776 | } |
| 777 | |
| 778 | |
| 779 | static void |
733 | 780 | atom_op_nop(atom_exec_context *ctx, int *ptr, int arg) |
734 | 781 | { |
735 | 782 | /* nothing */ |
… |
… |
atom_op_debug(atom_exec_context *ctx, int *ptr, int arg)
|
1004 | 1051 | } |
1005 | 1052 | |
1006 | 1053 | |
| 1054 | static void |
| 1055 | atom_op_processds(atom_exec_context *ctx, int *ptr, int arg) |
| 1056 | { |
| 1057 | uint16 val = U16(*ptr); |
| 1058 | (*ptr) += val + 2; |
| 1059 | TRACE("%s: Processds output: 0x%02X\n", __func__, val); |
| 1060 | } |
| 1061 | |
| 1062 | |
1007 | 1063 | static struct { |
1008 | 1064 | void (*func)(atom_exec_context *, int *, int); |
1009 | 1065 | int arg; |
… |
… |
static struct {
|
1130 | 1186 | { atom_op_shr, ATOM_ARG_PLL }, |
1131 | 1187 | { atom_op_shr, ATOM_ARG_MC }, |
1132 | 1188 | { atom_op_debug, 0 }, |
| 1189 | { atom_op_processds, 0}, |
| 1190 | { atom_op_mul32, ATOM_ARG_PS}, |
| 1191 | { atom_op_mul32, ATOM_ARG_WS}, |
| 1192 | { atom_op_div32, ATOM_ARG_PS}, |
| 1193 | { atom_op_div32, ATOM_ARG_WS} |
1133 | 1194 | }; |
1134 | 1195 | |
1135 | 1196 | |
diff --git a/src/add-ons/accelerants/radeon_hd/atombios/atom.h b/src/add-ons/accelerants/radeon_hd/atombios/atom.h
index 9e4ee72..18b91a6 100644
a
|
b
|
struct card_info {
|
78 | 78 | #define ATOM_CT_PS_MASK 0x7F |
79 | 79 | #define ATOM_CT_CODE_PTR 6 |
80 | 80 | |
81 | | #define ATOM_OP_CNT 123 |
| 81 | #define ATOM_OP_CNT 127 |
82 | 82 | #define ATOM_OP_EOT 91 |
83 | 83 | |
84 | 84 | #define ATOM_CASE_MAGIC 0x63 |