mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 09:01:40 +01:00 
			
		
		
		
	Some files that should have their copyrights checked are still placed on the copyright ignore list. - These entries have been tidied up - Copyrights of those files have been updated.
		
			
				
	
	
		
			31 lines
		
	
	
		
			816 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			816 B
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
 | 
						|
 *
 | 
						|
 * SPDX-License-Identifier: Apache-2.0
 | 
						|
 */
 | 
						|
 | 
						|
#include <stdlib.h>
 | 
						|
#include "riscv/instruction_decode.h"
 | 
						|
 | 
						|
typedef union {
 | 
						|
    struct {
 | 
						|
        unsigned int opcode: 7;
 | 
						|
        unsigned int rd: 5;
 | 
						|
        int imm_19_12: 8;
 | 
						|
        int imm_11: 1;
 | 
						|
        int imm_10_1: 10;
 | 
						|
        int imm20: 1;
 | 
						|
    };
 | 
						|
    unsigned int inst;
 | 
						|
} riscv_jal_intruction_t;
 | 
						|
 | 
						|
int riscv_decode_offset_from_jal_instruction(const intptr_t inst_addr)
 | 
						|
{
 | 
						|
    riscv_jal_intruction_t *jal_inst = (riscv_jal_intruction_t *)inst_addr;
 | 
						|
    // check if it's a valid JAL instruction
 | 
						|
    if (jal_inst->opcode != 0x6f && jal_inst->rd != 0) {
 | 
						|
        abort();
 | 
						|
    }
 | 
						|
    return (jal_inst->imm_10_1 | jal_inst->imm_11 << 10 | jal_inst->imm_19_12 << 11 | jal_inst->imm20 << 19) << 1;
 | 
						|
}
 |