[go: up one dir, main page]

CN119225831A - CPU implicit initialization method - Google Patents

CPU implicit initialization method Download PDF

Info

Publication number
CN119225831A
CN119225831A CN202411470757.7A CN202411470757A CN119225831A CN 119225831 A CN119225831 A CN 119225831A CN 202411470757 A CN202411470757 A CN 202411470757A CN 119225831 A CN119225831 A CN 119225831A
Authority
CN
China
Prior art keywords
ini
function
initialization
func
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411470757.7A
Other languages
Chinese (zh)
Inventor
王雨龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianjin Jinhang Computing Technology Research Institute
Original Assignee
Tianjin Jinhang Computing Technology Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianjin Jinhang Computing Technology Research Institute filed Critical Tianjin Jinhang Computing Technology Research Institute
Priority to CN202411470757.7A priority Critical patent/CN119225831A/en
Publication of CN119225831A publication Critical patent/CN119225831A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4403Processor initialisation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/47Retargetable compilers

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention discloses a CPU implicit initialization method, which comprises defining an initialization function, outputting an address of the initialization function to an independent section, simultaneously arranging the sections according to a set sequence, mapping an initialization function pointer to a corresponding section, checking mapping information, defining a function ini_start_func for searching a section starting position, defining a function ini_end_func for judging a section ending position, mapping the address of the function ini_start_func to the section ini_fn.0, mapping the address of the ini_end_func to the section ini_fn.z, performing address self-increasing operation, traversing pointer data of a section area, copying pointer data of the section area to funcptrnum, and operating the function in a function addressing mode. The invention outputs the initializing function address to the independent segment through ARMGCC compiler instruction, marks the starting address and the ending address through the null function address, traverses the function between the starting address and the ending address of the operating segment in the main function, and completes the operation work of the initializing function.

Description

CPU implicit initialization method
Technical Field
The invention belongs to the technical field of computer control, and relates to a CPU implicit initialization method.
Background
The ARM CPU software is initialized by firstly configuring a system clock, wherein a clock system in the ARM CPU is a core of the whole system and provides clock signals for other peripheral equipment and functions. Next, the clocks of the individual peripherals are configured as needed, the normal operation of the peripherals being dependent on the clock signal. GPIO (general purpose input output) is one of the most commonly used peripherals in ARM CPUs for connecting and controlling external devices. Therefore, parameters such as pin mode, output type, and the like of the GPIO need to be properly configured. Interrupts are an important mechanism for STM32 to handle external events. By configuring the interrupt priority and interrupt service routine, it is ensured that the system can quickly respond to external events. In addition to GPIOs and interrupts, other peripherals may need to be configured to meet specific application requirements. After all necessary configurations are completed, the user's application logic begins to run.
Disclosure of Invention
First, the technical problem to be solved
In the process of starting GD32, an on-board peripheral is required to be initialized in a main function, and the initialization functions of different peripheral are usually called sequentially according to the initialization functions of different peripheral, wherein the peripheral initialization functions are called in an APP file, and the initialization functions belong to a bottom layer function, so that the APP program and the bottom layer program are seriously coupled together, and if the bottom layer peripheral interface function is modified and the latter peripheral module is deleted, the application program is required to be correspondingly modified.
(II) technical scheme
In order to solve the technical problems, the invention provides a CPU implicit initialization method, which comprises the following steps:
S1, defining an initialization function by using a typedef key definition function pointer init_func, wherein the shape parameters and the return values of the function pointer are null type void.
The defined initialization functions comprise a network initialization function ini_wlan_fun and an ARINC 1553B bus initialization function, and a command line SHELL initialization function ini_shell_func.
S2, outputting the address of a function to an independent section by using ARMGCC compiler instruction __ attribute __ (section ("name")) and arranging the functions according to the set sequence.
The method comprises the steps of replacing x in a compiler with a segment name priority mode in a macro definition mode, for example, replacing x with an 'ini_fn' rank mode, wherein rank is the rank number 1, 2 and 3, and the like, for example, x parameters are represented by 'ini_fn', '1', 'ini_fn', '2', 'ini_fn', '3', the smaller the numerical value is, the compiler will place the corresponding function at the front position of a segment table.
The S3: ARMGCC compiler instruction __ attribute __ (used) instruction maps the initialization function pointer into the corresponding segment.
Setting a network initialization function ini_wlan_fun as a 1-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.1 ', setting an ARINC 1553B bus initialization function ini_1553b_func as a 2-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.2 ', setting a command line SHELL initialization function ini_shell_func as a 3-level priority, and mapping the command line SHELL_shell_func into a section ini_fn.3 '.
And S4, after compiling is completed, looking up in the map, and looking up mapping information in a map symbol table Image Symbol Table area.
The mapping information includes:
(1) The symbol name network initialization function ini_wlan_fun, the symbol address value of 0x200002c8, the symbol type of Data, the storage size of 4, and the network initialization function mapping on segment ini_fn.1.
(2) The symbol name ARINC 1553B bus initialization function ini_1553b_func, the symbol address value is 0x200002cc, the symbol type is Data, the storage size is 4, and the ARINC 1553B bus initialization function is mapped on the section ini_fn.2.
(3) The symbol name command line SHELL initialization function ini_shell_func, the symbol address value 0x200002d0, the symbol type Data, the memory size 4, and the command line SHELL initialization function map in segment ini_fn.3.
S5, defining a function ini_start_func by using the init_func function pointer definition defined in the step S1, wherein no operation is performed in the function to find the segment start position, and a function ini_end_func is defined to judge the segment end position, and no operation is performed in the function.
S6, mapping the address of the function ini_start_func into a segment 'ini_fn.0', the address of ini_end_func into a segment 'ini_fn.0', and the address of ini_end_func into a segment 'ini_fn.z', using ARMGCC compiler __ attribute __ (section ('name') instruction and __ attribute __ (used) instruction.
And S7, defining a function pointer variable funcptrnum in the step S1, assigning an initial value as an address of the function ini_start_func, performing address self-increasing operation, traversing pointer data of the extracted section area, copying the pointer data to funcptrnum, and operating the function in a function addressing mode.
(III) beneficial effects
According to the CPU implicit initialization method provided by the technical scheme, the initialization function address is output to the independent segment through ARMGCC compiler instructions, the starting address and the ending address are marked through the null function address, and the function between the starting address and the ending address of the operation segment is traversed in the main function, so that the operation work of the initialization function is completed.
Drawings
FIG. 1 is a flow chart of an embodiment of an implicit CPU initialization method.
Detailed Description
To make the objects, contents and advantages of the present invention more apparent, the following detailed description of the present invention will be given with reference to the accompanying drawings and examples.
Referring to fig. 1, the method for implicit initialization of a CPU according to the present embodiment includes the steps of:
S1, defining an initialization function by using a typedef key definition function pointer init_func, wherein the shape parameters and the return values of the function pointer are null type void.
The defined initialization functions comprise a network initialization function ini_wlan_fun and an ARINC 1553B bus initialization function, and a command line SHELL initialization function ini_shell_func.
S2, outputting the address of a function to an independent section by using ARMGCC compiler instruction __ attribute __ (section ("name")) and arranging the functions according to the set sequence.
The method comprises the steps of replacing x in a compiler with a segment name priority mode in a macro definition mode, for example, replacing x with an 'ini_fn' rank mode, wherein rank is the rank number 1, 2 and 3, and the like, for example, x parameters are represented by 'ini_fn', '1', 'ini_fn', '2', 'ini_fn', '3', the smaller the numerical value is, the compiler will place the corresponding function at the front position of a segment table.
The S3: ARMGCC compiler instruction __ attribute __ (used) instruction maps the initialization function pointer into the corresponding segment.
Setting a network initialization function ini_wlan_fun as a 1-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.1 ', setting an ARINC 1553B bus initialization function ini_1553b_func as a 2-level priority, mapping the network initialization function ini_wlan_fun into a section ini_fn.2 ', setting a command line SHELL initialization function ini_shell_func as a 3-level priority, and mapping the command line SHELL_shell_func into a section ini_fn.3 '.
And S4, after compiling is completed, looking up in the map, and looking up mapping information in a map symbol table Image Symbol Table area.
The mapping information includes:
(1) The symbol name network initialization function ini_wlan_fun, the symbol address value of 0x200002c8, the symbol type of Data, the storage size of 4, and the network initialization function mapping on segment ini_fn.1.
(2) The symbol name ARINC 1553B bus initialization function ini_1553b_func, the symbol address value is 0x200002cc, the symbol type is Data, the storage size is 4, and the ARINC 1553B bus initialization function is mapped on the section ini_fn.2.
(3) The symbol name command line SHELL initialization function ini_shell_func, the symbol address value 0x200002d0, the symbol type Data, the memory size 4, and the command line SHELL initialization function map in segment ini_fn.3.
S5, defining a function ini_start_func by using the init_func function pointer definition defined in the step S1, wherein no operation is performed in the function to find the segment start position, and a function ini_end_func is defined to judge the segment end position, and no operation is performed in the function.
S6, mapping the address of the function ini_start_func into a segment 'ini_fn.0', the address of ini_end_func into a segment 'ini_fn.0', and the address of ini_end_func into a segment 'ini_fn.z', using ARMGCC compiler __ attribute __ (section ('name') instruction and __ attribute __ (used) instruction.
And S7, defining a function pointer variable funcptrnum in the step S1, assigning an initial value as an address of the function ini_start_func, performing address self-increasing operation, traversing pointer data of the extracted section area, copying the pointer data to funcptrnum, and operating the function in a function addressing mode.
The section adds all the initializing functions into the defined input section in advance, and then sequentially takes out the initializing functions in the input section in the main function, so that the system can be initialized on the premise of not modifying the main function.
The foregoing is merely a preferred embodiment of the present invention, and it should be noted that modifications and variations could be made by those skilled in the art without departing from the technical principles of the present invention, and such modifications and variations should also be regarded as being within the scope of the invention.

Claims (10)

1.一种CPU隐式初始化方法,其特征在于,包括以下步骤:1. A CPU implicit initialization method, characterized in that it comprises the following steps: S1:使用typedef关键字定义函数指针init_func定义初始化函数;S1: Use the typedef keyword to define the function pointer init_func to define the initialization function; S2:使用ARMGCC编译器指令__attribute__((section("name")))把一个初始化函数的地址输出到一个独立的section中,同时按照设定顺序进行排列;S2: Use the ARMGCC compiler directive __attribute__((section("name"))) to output the address of an initialization function to a separate section and arrange them in the set order; S3:ARMGCC编译器指令__attribute__((used))指令将初始化函数指针映射到对应的段中;S3: The ARMGCC compiler instruction __attribute__((used)) directive maps the initialization function pointer to the corresponding segment; S4:编译完成后在.map中查看,在映射符号表Image Symbol Table区域查看到映射信息;S4: After the compilation is completed, check in .map and find the mapping information in the Image Symbol Table area; S5:使用步骤S1定义的init_func函数指针定义,定义函数ini_start_func,用来寻找段开始位置;以及定义函数ini_end_func,用来判断段结束位置;S5: using the init_func function pointer defined in step S1, define a function ini_start_func to find the start position of the segment; and define a function ini_end_func to determine the end position of the segment; S6:使用ARMGCC编译器__attribute__((section("name")))指令和__attribute__((used))指令将函数ini_start_func的地址映射到段"ini_fn.0"中,将ini_end_func的地址映射到段"ini_fn.0"中,将ini_end_func的地址映射到段"ini_fn.z"中;S6: Use the ARMGCC compiler __attribute__((section("name"))) and __attribute__((used)) instructions to map the address of the function ini_start_func to the segment "ini_fn.0", the address of ini_end_func to the segment "ini_fn.0", and the address of ini_end_func to the segment "ini_fn.z". S7:定义步骤S1中函数指针变量funcptrnum,初始值赋值为函数ini_start_func的地址,进行地址自增操作,遍历取出section区域的指针数据复制给funcptrnum,通过函数寻址方式运行此函数。S7: Define the function pointer variable funcptrnum in step S1, assign the initial value to the address of the function ini_start_func, perform the address self-increment operation, traverse and take out the pointer data in the section area and copy it to funcptrnum, and run this function through the function addressing mode. 2.如权利要求1所述的CPU隐式初始化方法,其特征在于,步骤S1中,函数指针的形参和返回值均为空类型void。2. The CPU implicit initialization method as described in claim 1 is characterized in that, in step S1, the formal parameters and return values of the function pointer are both of empty type void. 3.如权利要求2所述的CPU隐式初始化方法,其特征在于,步骤S1中,定义的初始化函数包括:网络初始化函数ini_wlan_fun,ARINC 1553B总线初始化函数,命令行SHELL初始化函数ini_shell_func。3. The CPU implicit initialization method as described in claim 2 is characterized in that, in step S1, the defined initialization functions include: a network initialization function ini_wlan_fun, an ARINC 1553B bus initialization function, and a command line SHELL initialization function ini_shell_func. 4.如权利要求3所述的CPU隐式初始化方法,其特征在于,步骤S2中,将编译器中的x以宏定义的方式替换为段名优先级方式,x替换为“ini_fn”rank方式,其中rank为等级序号1、2、3以此类推,x参数由”ini_fn””1”、”ini_fn””2”、”ini_fn””3”表示等级,数值越小,对应的函数在段表中的位置越靠前。4. The CPU implicit initialization method as described in claim 3 is characterized in that, in step S2, x in the compiler is replaced with a segment name priority method in a macro definition manner, and x is replaced with an "ini_fn" rank method, where rank is a rank number 1, 2, 3 and so on, and the x parameter is represented by "ini_fn" "1", "ini_fn" "2", "ini_fn" "3" to represent the rank, and the smaller the value, the closer the corresponding function is to the front of the segment table. 5.如权利要求4所述的CPU隐式初始化方法,其特征在于,步骤S3中,设置网络初始化函数ini_wlan_fun为1级优先级,映射到段.ini_fn.1"中,设置ARINC 1553B总线初始化函数ini_1553b_func为2级优先级,映射到段.ini_fn.2"中,设置命令行SHELL初始化函数ini_shell_func为3级优先级,映射到段.ini_fn.3"中。5. The CPU implicit initialization method as described in claim 4 is characterized in that in step S3, the network initialization function ini_wlan_fun is set to level 1 priority and mapped to segment .ini_fn.1", the ARINC 1553B bus initialization function ini_1553b_func is set to level 2 priority and mapped to segment .ini_fn.2", and the command line SHELL initialization function ini_shell_func is set to level 3 priority and mapped to segment .ini_fn.3". 6.如权利要求5所述的CPU隐式初始化方法,其特征在于,步骤S3中,映射信息包括:符号名网络初始化函数ini_wlan_fun、符号名ARINC 1553B总线初始化函数ini_1553b_func和符号名命令行SHELL初始化函数ini_shell_func。6. The CPU implicit initialization method as claimed in claim 5, characterized in that in step S3, the mapping information includes: a symbolic name network initialization function ini_wlan_fun, a symbolic name ARINC 1553B bus initialization function ini_1553b_func and a symbolic name command line SHELL initialization function ini_shell_func. 7.如权利要求6所述的CPU隐式初始化方法,其特征在于,步骤S3中,符号名网络初始化函数ini_wlan_fun中,符号地址value为0x200002c8,符号类型为Data,存储大小size为4,网络初始化函数映射在段.ini_fn.1。7. The CPU implicit initialization method as described in claim 6 is characterized in that in step S3, in the symbolic name network initialization function ini_wlan_fun, the symbolic address value is 0x200002c8, the symbolic type is Data, the storage size size is 4, and the network initialization function is mapped in segment .ini_fn.1. 8.如权利要求7所述的CPU隐式初始化方法,其特征在于,步骤S3中,符号名ARINC1553B总线初始化函数ini_1553b_func中,符号地址value为0x200002cc,符号类型为Data,存储大小size为4,ARINC 1553B总线初始化函数映射在段.ini_fn.2。8. The CPU implicit initialization method as described in claim 7 is characterized in that, in step S3, in the symbol name ARINC1553B bus initialization function ini_1553b_func, the symbol address value is 0x200002cc, the symbol type is Data, the storage size size is 4, and the ARINC 1553B bus initialization function is mapped in segment .ini_fn.2. 9.如权利要求8所述的CPU隐式初始化方法,其特征在于,步骤S3中,符号名命令行SHELL初始化函数ini_shell_func中,符号地址value为0x200002d0,符号类型为Data,存储大小size为4,以及命令行SHELL初始化函数映射在段.ini_fn.3。9. The CPU implicit initialization method as described in claim 8 is characterized in that in step S3, in the symbolic name command line SHELL initialization function ini_shell_func, the symbolic address value is 0x200002d0, the symbolic type is Data, the storage size size is 4, and the command line SHELL initialization function is mapped in segment .ini_fn.3. 10.如权利要求9所述的CPU隐式初始化方法,其特征在于,步骤S7中,section事先将所有的初始化函数加入到定义的输入段中,然后再在main函数中将这个输入段中初始化函数依次取出,在不修改main函数的前提下完成对系统的初始化。10. The CPU implicit initialization method as described in claim 9 is characterized in that in step S7, section adds all initialization functions to the defined input section in advance, and then takes out the initialization functions in this input section in turn in the main function, completing the initialization of the system without modifying the main function.
CN202411470757.7A 2024-10-21 2024-10-21 CPU implicit initialization method Pending CN119225831A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411470757.7A CN119225831A (en) 2024-10-21 2024-10-21 CPU implicit initialization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411470757.7A CN119225831A (en) 2024-10-21 2024-10-21 CPU implicit initialization method

Publications (1)

Publication Number Publication Date
CN119225831A true CN119225831A (en) 2024-12-31

Family

ID=93945128

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411470757.7A Pending CN119225831A (en) 2024-10-21 2024-10-21 CPU implicit initialization method

Country Status (1)

Country Link
CN (1) CN119225831A (en)

Similar Documents

Publication Publication Date Title
EP4560478A1 (en) Verification system, verification method, electronic device, and storage medium
US6338109B1 (en) Microcontroller development system and applications thereof for development of a universal serial bus microcontroller
US6370635B2 (en) Dual ROM microprogrammable microcontroller and universal serial bus microcontroller development system
US9652570B1 (en) Automatic implementation of a customized system-on-chip
CN113849433A (en) Bus controller execution method and device, bus controller, computer equipment and storage medium
US20250077240A1 (en) Method, system, and device for software and hardware component configuration and content generation
JP7420804B2 (en) Data communication with improved speed modes
US20070283260A1 (en) Human-machine Interface System with Device Bridge and Method for Designing and Operating the Same
JP2009181579A (en) Method, subsystem and system for calling functions
US11392406B1 (en) Alternative interrupt reporting channels for microcontroller access devices
CN119225831A (en) CPU implicit initialization method
US12093201B2 (en) Method, system, and device for software and hardware component configuration and content generation
CN117931404A (en) Multi-application switching method, device, equipment and medium based on FPGA
CN117193872A (en) Chip starting firmware device and method based on symbol table dynamic execution
CN117350205A (en) Verification methods, devices, electronic equipment and storage media for chips
KR20250042701A (en) Reconfigurable neural engine with extensible instruction set architecture
CN112949243B (en) Parameter configuration method and device, computer equipment and storage medium
CN112257359B (en) Debugging method, device, debugging system and storage medium for data waveform
CN116088864A (en) Assembling method, disassembling method, apparatus and storage medium
CN112395727B (en) CAE-based vehicle durability condition creation method and device
JP5577619B2 (en) Logic circuit design device
US12039294B2 (en) Device and method for handling programming language function
JPS5856277A (en) Method and device for information processing
JP2001076027A (en) Method and apparatus for simulation in system desgining stage and storage medium with program stored thereof
CN102591820A (en) IDMA (interleave division multiple access) bus bridge device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination