diff --git a/VC4-lib/CMakeLists.txt b/VC4-lib/CMakeLists.txt deleted file mode 100644 index 57f0671..0000000 --- a/VC4-lib/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_library(VC4-lib - src/0-instruction_length.c) -target_include_directories(VC4-lib PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/inc - ${PROJECT_SOURCE_DIR}/common - ) diff --git a/VC4-lib/inc/vc4isa.h b/VC4-lib/inc/vc4isa.h deleted file mode 100644 index 5fa957e..0000000 --- a/VC4-lib/inc/vc4isa.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * VideoCore IV Instruction Set Architecture Library - * For Use With VC4Dis (Name Pending) - * - * MIT License - * - * Copyright (c) 2023 Wyatt Whitfield - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*/ - -#ifndef vc4isa_libh -#define vc4isa_libh - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "common.h" - - -// Structure defining the address where the instruction came from, the -// textual name, actual contents, and the length of the contents, as well -// as the arguments contained by the text` -struct instruction_node { - unsigned int address; - // The actual name is fixed - char *name; - byte *content; - unsigned int content_length; - argument *arg; -}; - -// Get the number of bytes in the next instruction -unsigned int instruction_length(unsigned char* input); - -// Get the instruction node of the instruction being read in -struct instruction_node* next_instruction(unsigned char* input, unsigned int instruction_size); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/VC4-lib/src/0-instruction_length.c b/VC4-lib/src/0-instruction_length.c deleted file mode 100644 index 4306393..0000000 --- a/VC4-lib/src/0-instruction_length.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "vc4isa.h" -unsigned int next_instruction_is(unsigned char* input) -{ - // Copy first byte of next instruction off the stack for decode - unsigned char val = *input & 0xF8 ; - switch (val) { - case 0xF8: - return 10; - case 0xF0: - return 6; - } - val = val & 0xF0; - switch (val) { - case 0xE0: - return 6; - } - val = val & 0x80; - switch (val) { - case 0x80: - return 4; - case 0x00: - return 2; - } -} diff --git a/VC4-lib/src/1-next_instruction.c b/VC4-lib/src/1-next_instruction.c deleted file mode 100644 index 81e83c5..0000000 --- a/VC4-lib/src/1-next_instruction.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include "vc4isa.h" - -// Forward definition of functions to populate instruction_node based on input -void vector80_lookup(struct instruction_node* process, byte* input); -void vector48_lookup(struct instruction_node* process, byte* input); -void scalar48_lookup(struct instruction_node* process, byte* input); -void scalar32_lookup(struct instruction_node* process, byte* input); -void scalar16_lookup(struct instruction_node* process, byte* input); - -// Perform a lookup on the instruction based on its value. -struct instruction_node* next_instruction(byte* input, unsigned int instruction_size) { - struct instruction_node* rval = malloc(sizeof(struct instruction_node)); - - switch (instruction_size) { - case 10: - // Handle Vector80's here - vector80_lookup(rval, input); - break; - case 6: - // Handle Vector48's and Scalar48's here - // Vector 48's will eval to 0xf0, scalar evals to 0xe0 - if ((input[0] & 0xf0) == 0xf0) { - vector48_lookup(rval, input); - return rval; - } else { - return rval; - scalar48_lookup(rval, input); - } - break; - case 4: - // Handle Scalar 32's here - scalar32_lookup(rval, input); - return rval; - break; - case 2: - // Handle Scalar 16's or data half-words here. - scalar16_lookup(rval, input); - return rval; - break; - } - - // TODO: Return this function. - return rval; -} - - -/* This function takes a pointer to an instruction_node and an array of input - * bytes whose length is determined elsewhere in the library. It's not intended - * for use outside of this library because there's no other way to determine w/ - * absolute certainty that the pointer to a byte[6] actually points to 6 bytes - * in memory. - * - * Based on the value of the bytes given as input, this function modifies the - * provided instruction_node's name, value, content, and eventually argument - * nodes */ -void scalar48_lookup(struct instruction_node* process, byte* input) { - uint16_t i_hword; - uint32_t d_word; - - // copy first 2 bytes into instruction halfword variable, last 4 into - // data word variable - memcpy(&i_hword, input, 2); - memcpy(&d_word, (input+2), 4); - - switch (i_hword) { - case 0xE000: - process->name = "j"; - // TODO - Append arguments - break; - case 0xE100: - process->name = "b"; - // TODO - Append arguments - break; - case 0xE200: - process->name = "jl"; - // TODO - Append arguments - break; - case 0xE300: - process->name = "bl"; - // TODO - Append arguments - break; - } - - if ((i_hword & 0xFFE0) == 0xE500) { - process->name = "add"; - } - - switch (i_hword & 0xFF00) { - case 0xE600: - - break; - case 0xE700: - if (i_hword & 0x0020) { - process->name = "st"; - } else { - process->name = "ld"; - } - break; - } - - memcpy(process->content, input, 6); - process->content_length = 6; - - - return; -} diff --git a/common/common.h b/common/common.h deleted file mode 100644 index fed3080..0000000 --- a/common/common.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Disassembler Common Types - * For Use With VC4Dis (Name Pending) - * - * MIT License - * - * Copyright (c) 2023 Wyatt Whitfield - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -*/ - -#ifndef disassembler_common_types -#define disassembler_common_types - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef uint8_t byte; - -enum instruction_types { - DATA=0, - MATH_OP=1, - LOGIC_OP=1, - MEMORY_OP, - COND_KNOWN_BRANCH, - IMMED_KNOWN_BRANCH, - COND_COMPUTED_BRANCH, - IMMED_COMPUTED_BRANCH, - INTERRUPT, - FLOAT_OP, -}; -typedef enum instruction_types itypes; - -enum argument_types { - CONDITION, - OPERATION, - FLOAT_OPERATION, - DATA_WIDTH, - REGISTER_REF, - COMPUTED_OFFSET_2X, - COMPUTED_OFFSET_4X, - OFFSET_DIRECT, - IMMEDIATE, - -}; -typedef enum argument_types atypes; - -struct argument { - atypes type; - byte* content; -}; - -typedef struct argument argument; - - - - -#ifdef __cplusplus -} -#endif -#endif