CN114398029A - Operating system based on C language virtual machine - Google Patents
Operating system based on C language virtual machine Download PDFInfo
- Publication number
- CN114398029A CN114398029A CN202210044263.7A CN202210044263A CN114398029A CN 114398029 A CN114398029 A CN 114398029A CN 202210044263 A CN202210044263 A CN 202210044263A CN 114398029 A CN114398029 A CN 114398029A
- Authority
- CN
- China
- Prior art keywords
- language
- virtual machine
- layer
- operating system
- system based
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/37—Compiler construction; Parser generation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
Description
技术领域technical field
本发明涉及智能卡虚拟机领域,尤其涉及一种基于C语言虚拟机的操作系统。The invention relates to the field of smart card virtual machines, in particular to an operating system based on a C language virtual machine.
背景技术Background technique
目前,在智能卡领域,为了方便应用在平台间移植使用,且达到上层应用开发的简化,一般通过虚拟机来屏蔽掉底层平台的不同。现有技术中,一般以智能卡硬件系统为基础,通过软件的方式构造一个基于JavaCard虚拟机来支持Java程序下载、安装、运行的操作系统。At present, in the field of smart cards, in order to facilitate the migration of applications between platforms and to simplify the development of upper-layer applications, a virtual machine is generally used to shield the differences in the underlying platforms. In the prior art, generally based on a smart card hardware system, a JavaCard-based virtual machine is constructed by means of software to support the downloading, installation and running of Java programs.
但是,现有操作系统存在以下问题:一方面现有操作系统中的Java虚拟机是由国外公司开发,因此现有操作系统不具备国内自主知识产权;另一方面现有操作系统中的Java虚拟机为面向对象的使用方法,其执行速度较显缓慢,从而导致现有操作系统中的应用程序在某些平台上运行时性能不能达到最佳效果。However, the existing operating system has the following problems: on the one hand, the Java virtual machine in the existing operating system is developed by a foreign company, so the existing operating system does not have domestic independent intellectual property rights; on the other hand, the Java virtual machine in the existing operating system The machine is an object-oriented method, and its execution speed is relatively slow, so that the performance of the application program in the existing operating system cannot reach the best effect when running on some platforms.
发明内容SUMMARY OF THE INVENTION
本发明的主要目的在于提供一种基于C语言虚拟机的操作系统,旨在解决现有技术中,在嵌入式开发中,缺少一种性能更高更普适于用户的基于C语言虚拟机的操作系统的技术问题。The main purpose of the present invention is to provide an operating system based on a C language virtual machine, aiming to solve the problem of the lack of a C language virtual machine-based operating system with higher performance and more generality for users in the embedded development in the prior art. Technical issues with the operating system.
本发明提供一种基于C语言虚拟机的操作系统,所述基于C语言虚拟机的操作系统包括应用编程接口层、虚拟机层以及全局平台管理层;所述应用编程接口层用于为C语言应用程序提供应用编程接口对应的系统标准库函数;所述虚拟机层用于为C语言应用程序提供运行时环境、虚拟机解释器功能,以实现相应的C语言应用程序功能;所述全局平台管理层用于下载C语言应用程序的目标二进制文件对应的下载脚本,以及实例化安装C语言应用程序。The present invention provides an operating system based on a C language virtual machine, the operating system based on the C language virtual machine includes an application programming interface layer, a virtual machine layer and a global platform management layer; the application programming interface layer is used for C language The application program provides the system standard library function corresponding to the application programming interface; the virtual machine layer is used to provide the C language application program with a runtime environment and virtual machine interpreter functions, so as to realize the corresponding C language application program function; the global platform The management layer is used to download the download script corresponding to the target binary file of the C language application, and instantiate the installation of the C language application.
可选的,所述虚拟机层由虚拟机堆栈、虚拟机字节码、运行时数据堆、虚拟机解释器组成。Optionally, the virtual machine layer is composed of a virtual machine stack, a virtual machine bytecode, a runtime data heap, and a virtual machine interpreter.
可选的,所述虚拟机堆栈用于存储C语言应用程序的函数参数、变量、操作缓存。Optionally, the virtual machine stack is used to store function parameters, variables, and operation caches of the C language application.
可选的,所述运行时数据堆用于存储C语言应用程序的局部数组和结构体变量的虚拟数据集合。Optionally, the runtime data heap is used for storing virtual data sets of local arrays and structure variables of the C language application.
可选的,所述虚拟机字节码包含预设个数的C语言应用程序的变量、函数以及表达式对应的伪汇编字节码。Optionally, the virtual machine bytecode includes a preset number of variables, functions, and pseudo-assembly bytecodes corresponding to expressions of the C language application.
可选的,所述虚拟机解释器用于循环获取、解析和执行字节码的实现函数,以实现字节码对应的C语言应用程序功能。Optionally, the virtual machine interpreter is used to obtain, parse and execute the implementation function of the bytecode in a loop, so as to realize the function of the C language application program corresponding to the bytecode.
可选的,所述基于C语言虚拟机的操作系统用于C语言应用程序下载、安装与运行,其中,所述C语言应用程序中编写的代码包含C语言的变量、函数、表达式和应用编程接口的字节码。Optionally, the operating system based on the C language virtual machine is used to download, install and run a C language application program, wherein the code written in the C language application program includes C language variables, functions, expressions and applications. The bytecode of the programming interface.
可选的,在所述C语言应用程序编译过程中,将所述C语言应用程序对应的函数、变量和表达式通过前端编译,生成语法树;将语法树根据已定义的虚拟机字节码进行后端编译,生成目标二进制文件。Optionally, in the process of compiling the C language application, the functions, variables and expressions corresponding to the C language application are compiled through the front end to generate a syntax tree; the syntax tree is based on the defined virtual machine bytecodes. Backend compilation is performed to generate the target binary.
可选的,所述全局平台管理层用于:Optionally, the global platform management layer is used for:
解析下载脚本对应的C语言应用程序的目标二进制文件的结构中各个组件信息;Parse each component information in the structure of the target binary file of the C language application program corresponding to the download script;
基于操作系统中的已有数据对各个组件中需要链接的部分进行链接。The parts that need to be linked in each component are linked based on the existing data in the operating system.
可选的,所述基于C语言虚拟机的操作系统还包括芯片硬件层、硬件抽象层、核心层;所述芯片硬件层由芯片硬件、固件库和算法库组成;所述硬件抽象层用于对所述芯片硬件层的固件库和算法库进行抽象封装,为操作系统提供统一的基本功能接口;所述核心层用于对所述硬件抽象层进行模块封装,使用所述硬件抽象层所提供的统一的基本功能接口,以实现操作系统中应用编程接口层、虚拟机层以及全局平台管理层的基本功能。Optionally, the operating system based on the C language virtual machine further includes a chip hardware layer, a hardware abstraction layer, and a core layer; the chip hardware layer is composed of chip hardware, a firmware library and an algorithm library; the hardware abstraction layer is used for The firmware library and algorithm library of the chip hardware layer are abstractly encapsulated to provide a unified basic function interface for the operating system; the core layer is used for module encapsulation of the hardware abstraction layer, using the hardware abstraction layer provided by the The unified basic function interface of the operating system can realize the basic functions of the application programming interface layer, the virtual machine layer and the global platform management layer in the operating system.
本发明提供一种基于C语言虚拟机的操作系统,所述基于C语言虚拟机的操作系统包括应用编程接口层、虚拟机层以及全局平台管理层;所述应用编程接口层用于为C语言应用程序提供应用编程接口对应的系统标准库函数;所述虚拟机层用于为C语言应用程序提供运行时环境、虚拟机解释器功能,以实现相应的C语言应用程序功能;所述全局平台管理层用于下载C语言应用程序的目标二进制文件对应的下载脚本,以及实例化安装C语言应用程序。本发明提供了一种性能更高更普适于用户的基于C语言虚拟机的操作系统,所述操作系统支持C语言应用程序下载、安装与运行,在保障了C语言应用程序的性能需求的同时,满足了C语言应用程序可以跨平台执行的需求。The present invention provides an operating system based on a C language virtual machine, the operating system based on the C language virtual machine includes an application programming interface layer, a virtual machine layer and a global platform management layer; the application programming interface layer is used for C language The application program provides the system standard library function corresponding to the application programming interface; the virtual machine layer is used to provide the C language application program with a runtime environment and virtual machine interpreter functions, so as to realize the corresponding C language application program function; the global platform The management layer is used to download the download script corresponding to the target binary file of the C language application, and instantiate the installation of the C language application. The present invention provides a C language virtual machine-based operating system with higher performance and more generality for users. The operating system supports the downloading, installation and running of C language application programs, while ensuring the performance requirements of C language application programs. At the same time, it satisfies the requirement that C language applications can be executed across platforms.
附图说明Description of drawings
图1为本发明实施例方案中涉及的基于C语言虚拟机的操作系统的层级示意图。FIG. 1 is a hierarchical schematic diagram of an operating system based on a C language virtual machine involved in an embodiment of the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.
本发明实施例提供了一种基于C语言虚拟机的操作系统。The embodiment of the present invention provides an operating system based on a C language virtual machine.
参照图1,图1为本发明基于C语言虚拟机的操作系统一实施例的层级示意图。Referring to FIG. 1 , FIG. 1 is a hierarchical schematic diagram of an embodiment of an operating system based on a C language virtual machine of the present invention.
在本发明基于C语言虚拟机的操作系统一实施例中,所述基于C语言虚拟机的操作系统包括应用编程接口层、虚拟机层以及全局平台管理层;所述应用编程接口层用于为C语言应用程序提供应用编程接口对应的系统标准库函数;所述虚拟机层用于为C语言应用程序提供运行时环境、虚拟机解释器功能,以实现相应的C语言应用程序功能;所述全局平台管理层用于下载C语言应用程序的目标二进制文件对应的下载脚本,以及实例化安装C语言应用程序。In an embodiment of the operating system based on the C language virtual machine of the present invention, the operating system based on the C language virtual machine includes an application programming interface layer, a virtual machine layer and a global platform management layer; the application programming interface layer is used for The C language application program provides system standard library functions corresponding to the application programming interface; the virtual machine layer is used to provide the C language application program with a runtime environment and virtual machine interpreter functions to realize the corresponding C language application program functions; the The global platform management layer is used to download the download script corresponding to the target binary file of the C language application, and instantiate the installation of the C language application.
本实施例中,所述基于C语言虚拟机的操作系统包括应用编程接口层、虚拟机层以及全局平台管理层。In this embodiment, the operating system based on the C language virtual machine includes an application programming interface layer, a virtual machine layer and a global platform management layer.
其中,所述应用编程接口层用于为C语言应用程序提供应用编程接口对应的系统标准库函数。C语言应用程序是由开发者按照C语言规则,结合操作系统所提供的应用编程接口来编写的可执行程序。在编译器编写所述C语言应用程序的代码文件时,所编写的代码文件中所述应用编程接口的对应的系统标准库函数是由操作系统的应用编程接口层来定义的。在C语言应用程序运行时,可以直接调用所述应用编程接口的对应的系统标准库函数,来实现对应的功能。Wherein, the application programming interface layer is used to provide system standard library functions corresponding to the application programming interface for C language applications. A C language application is an executable program written by the developer in accordance with the C language rules and in combination with the application programming interface provided by the operating system. When the compiler writes the code file of the C language application, the corresponding system standard library function of the application programming interface in the written code file is defined by the application programming interface layer of the operating system. When the C language application program is running, the corresponding system standard library function of the application programming interface can be directly called to realize the corresponding function.
所述虚拟机层用于为C语言应用程序提供运行时环境、虚拟机解释器功能,以实现相应的C语言应用程序功能。虚拟机层是C语言应用程序在操作系统上执行的基础。在编译器编写所述C语言应用程序时,需要结合虚拟机层所定义的虚拟机字节码来对应生成C语言应用程序的代码文件。当运行所述C语言应用程序,通过虚拟机层所提供的运行时环境功能来进行C语言应用程序操作的内存读写等,其中,所述运行时环境功能包括防火墙、生命周期管理、逻辑通道管理、原子和事务机制等功能。当运行所述C语言应用程序,通过虚拟机层所提供的虚拟机解释器功能循环获取C语言应用程序的字节码,并解析和执行这些字节码,实现相应的C语言应用程序功能。The virtual machine layer is used to provide a runtime environment and virtual machine interpreter functions for C language applications, so as to realize corresponding C language application functions. The virtual machine layer is the basis for the execution of C language applications on the operating system. When the compiler writes the C language application, the code file of the C language application needs to be correspondingly generated in combination with the virtual machine bytecode defined by the virtual machine layer. When running the C language application program, the memory read and write operations of the C language application program are performed through the runtime environment function provided by the virtual machine layer, wherein the runtime environment function includes firewall, life cycle management, logical channel Features such as management, atomic and transaction mechanisms. When running the C language application program, the bytecode of the C language application program is cyclically obtained through the virtual machine interpreter function provided by the virtual machine layer, and parses and executes the bytecode to realize the corresponding C language application program function.
所述全局平台管理层用于下载C语言应用程序的目标二进制文件对应的下载脚本,以及实例化安装C语言应用程序。全局平台管理层主要用于操作系统的内容管理,包括认证、密钥管理、数据管理以及下载、安装和删除C语言应用程序的功能。所述全局平台管理层在通过编译器编写完C语言应用程序的实现代码的目标二进制文件后,将目标二进制文件通过转换工具转换成GP格式的下载脚本,再将C语言应用程序的目标二进制文件对应的下载脚本通过全局平台管理层下载到操作系统中,并实例化安装C语言应用程序。在下载安装完成后,通过操作系统的全局平台管理层管理已下载的C语言应用程序和安装的C语言应用程序实例的空间、数据和注册表信息。The global platform management layer is used to download the download script corresponding to the target binary file of the C language application, and instantiate the installation of the C language application. The global platform management layer is mainly used for the content management of the operating system, including authentication, key management, data management, and the functions of downloading, installing and deleting C language applications. After the global platform management layer has written the target binary file of the realization code of the C language application program by the compiler, the target binary file is converted into the download script of the GP format by the conversion tool, and then the target binary file of the C language application program is converted. The corresponding download script is downloaded to the operating system through the global platform management layer, and the C language application is instantiated and installed. After the download and installation are completed, the space, data and registry information of the downloaded C language application program and the installed C language application program instance are managed through the global platform management layer of the operating system.
进一步,一实施例中,所述虚拟机层由虚拟机堆栈、虚拟机字节码、运行时数据堆、虚拟机解释器组成。Further, in an embodiment, the virtual machine layer is composed of a virtual machine stack, a virtual machine bytecode, a runtime data heap, and a virtual machine interpreter.
本实施例中,所述虚拟机层由虚拟机堆栈、虚拟机字节码、运行时数据堆、虚拟机解释器组成。其中,上述虚拟机层的各组成部分分别满足C语言应用程序的编译与解释运行时的对应功能需求。In this embodiment, the virtual machine layer is composed of a virtual machine stack, a virtual machine bytecode, a runtime data heap, and a virtual machine interpreter. Wherein, each component of the above-mentioned virtual machine layer respectively meets the corresponding functional requirements of the C language application program when compiling and interpreting the runtime.
进一步,一实施例中,所述虚拟机堆栈用于存储C语言应用程序的函数参数、变量、操作缓存。Further, in one embodiment, the virtual machine stack is used to store function parameters, variables, and operation caches of the C language application.
本实施例中,所述虚拟机堆栈用于存储C语言应用程序的函数参数、变量、操作缓存。其中,所述虚拟机堆栈包括:参数栈、变量栈、操作栈、方法栈、异常栈。在所述虚拟机堆栈中,所述参数栈用于传递C语言应用程序代码中的函数参数,所述函数参数由堆栈压栈输入,在C语言应用程序代码中的函数执行时从堆栈出栈获取;所述变量栈用于存储C语言应用程序代码中的函数局部变量,其中所述函数局部变量中的数组和结构体以对象索引形式存在;所述操作栈用于存储运算C语言应用程序代码中的表达式的中间结果;所述方法栈用于保存和恢复C语言应用程序代码中的函数调用时的堆栈;所述异常栈用于存储以Try\catch关键字所捕获的C语言应用程序代码执行异常时的数据。In this embodiment, the virtual machine stack is used to store function parameters, variables, and operation caches of the C language application. The virtual machine stack includes: a parameter stack, a variable stack, an operation stack, a method stack, and an exception stack. In the virtual machine stack, the parameter stack is used to transfer function parameters in the C language application code, the function parameters are pushed and input by the stack, and are popped from the stack when the function in the C language application code is executed. Obtaining; the variable stack is used to store the function local variables in the C language application code, wherein the arrays and structures in the function local variables exist in the form of object indexes; the operation stack is used to store the operation C language application program The intermediate result of the expression in the code; The method stack is used to save and restore the stack when the function in the C language application code is called; The exception stack is used to store the C language application captured by the Try\catch keyword Data when the program code executes abnormally.
进一步,一实施例中,所述运行时数据堆用于存储C语言应用程序的局部数组和结构体变量的虚拟数据集合。Further, in one embodiment, the runtime data heap is used for storing virtual data sets of local arrays and structure variables of the C language application.
本实施例中,所述运行时数据堆用于存储C语言应用程序的局部数组和结构体变量的虚拟数据集合。所述运行时数据堆是与用户数据存储区相对应的内存空间,主要用于存储C语言应用程序代码中对应的函数局部数组和结构体变量的实际物理数据,为其虚拟对象提供临时存储空间,所述临时存储空间为系统RAM区,与所述虚拟机堆栈隔离。其中,所述C语言应用程序代码中对应的每个局部数组或结构体变量的对象索引都与运行时数据堆中的地址一一对应。所述运行时数据堆的数据内容还包括包括成员数据、虚拟数据集合安全维护数据,如上下文、大小、类型等。所述运行时数据堆能够统一变量栈中的数据结构,释放虚拟机堆栈压力,并且提供统一的虚拟数据集合结构,保证数组和结构体变量的数据安全,以及对RAM数据存储和访问性能优异。In this embodiment, the runtime data heap is used to store the virtual data sets of local arrays and structure variables of the C language application. The runtime data heap is a memory space corresponding to the user data storage area, and is mainly used to store the actual physical data of the corresponding function local arrays and structure variables in the C language application code, and to provide temporary storage space for its virtual objects. , the temporary storage space is a system RAM area, which is isolated from the virtual machine stack. Wherein, the object index of each local array or structure variable corresponding to the C language application code is in one-to-one correspondence with the address in the runtime data heap. The data content of the runtime data heap also includes member data and virtual data collection security maintenance data, such as context, size, type, and the like. The runtime data heap can unify the data structure in the variable stack, release the stack pressure of the virtual machine, and provide a unified virtual data set structure, ensure the data security of arrays and structure variables, and have excellent RAM data storage and access performance.
进一步,一实施例中,所述虚拟机字节码包含预设个数的C语言应用程序的变量、函数以及表达式对应的伪汇编字节码。Further, in one embodiment, the virtual machine bytecode includes a preset number of pseudo-assembly bytecodes corresponding to variables, functions and expressions of the C language application.
本实施例中,所述虚拟机字节码包含预设个数的C语言应用程序的变量、函数以及表达式对应的伪汇编字节码。C语言应用程序可以访问所存储的虚拟机字节码。其中,所述虚拟机所包含的预设个数的伪汇编字节码,在变量方面是包含基础类型的全局变量与局部变量、数组与结构体以及应用结构体;在函数方面是包含进行C语言应用程序所对应系统模块的应用编程接口的调用函数以及普通应用方法的调用函数;在表达式方面是包含C语言应用程序所对应的条件控制语句、运算操作符语句、异常捕获语句等语句。In this embodiment, the virtual machine bytecode includes a preset number of variables, functions, and pseudo-assembly bytecodes corresponding to expressions of the C language application. C language applications can access the stored virtual machine bytecode. Among them, the preset number of pseudo-assembly bytecodes included in the virtual machine include, in terms of variables, global variables and local variables of basic types, arrays and structures, and application structures; in terms of functions, it includes performing C The calling function of the application programming interface of the system module corresponding to the language application program and the calling function of the common application method; in terms of expressions, it includes the conditional control statements, operation operator statements, exception catch statements and other statements corresponding to the C language application program.
其中,所述虚拟机字节码在基本C语言应用程序对应的字节码定义的基础上新增了部分特有的语言特性:第一,在变量定义时增加const关键字修饰,与存储在RAM存储区的普通全局变量不同,增加const关键字修饰的全局变量存储在操作系统的NVM存储区。第二,在函数定义时增加SIO关键字修饰,来区分C语言应用程序的应用函数是否允许其他C语言应用程序通过共享接口机制来访问。有SIO修饰的函数表示该应用函数声明为共享接口类型,允许其他应用通过共享接口机制访问该函数;没有SIO修饰的函数只能在本应用模块中使用,其他应用不能访问。第三,自定义关键字类型表示系统模块的应用编程接口中定义的特殊结构体变量类型,该结构体变量的成员对外不可见,C语言应用程序可以通过应用编程接口层的应用编程接口访问这些结构体变量。第四,异常捕获机制,支持以try\catch关键字来捕获C语言应用程序代码中的异常,捕获后由C语言应用程序处理异常。Among them, the virtual machine bytecode adds some unique language features on the basis of the bytecode definition corresponding to the basic C language application. Unlike ordinary global variables in the storage area, the global variables modified with the const keyword are stored in the NVM storage area of the operating system. Second, add the SIO keyword modifier when the function is defined to distinguish whether the application function of the C language application program allows other C language application programs to access through the shared interface mechanism. A function decorated with SIO indicates that the application function is declared as a shared interface type, allowing other applications to access the function through the shared interface mechanism; functions without SIO decoration can only be used in this application module, and cannot be accessed by other applications. Third, the custom keyword type represents the special structure variable type defined in the application programming interface of the system module. The members of the structure variable are not visible to the outside world, and the C language application can access these variables through the application programming interface of the application programming interface layer. structure variable. Fourth, the exception capture mechanism supports the use of the try\catch keyword to capture exceptions in the C language application code, and the C language application program handles the exception after the capture.
进一步,一实施例中,所述虚拟机解释器用于循环获取、解析和执行字节码的实现函数,以实现字节码对应的C语言应用程序功能。Further, in an embodiment, the virtual machine interpreter is used to obtain, parse and execute the implementation functions of the bytecode in a loop, so as to realize the function of the C language application program corresponding to the bytecode.
本实施例中,所述虚拟机解释器用于循环获取、解析和执行字节码的实现函数,以实现字节码对应的C语言应用程序功能。其具体作用流程如下:虚拟机解释器从C语言应用程序的目标二进制文件对应的下载脚本中读取字节码数据,再查找到所述字节码数据对应的代码实现函数后,调用字节码的实现函数,实现字节码对应的C语言应用程序功能。In this embodiment, the virtual machine interpreter is used to cyclically obtain, parse and execute the implementation functions of the bytecode, so as to realize the function of the C language application program corresponding to the bytecode. Its specific action process is as follows: the virtual machine interpreter reads the bytecode data from the download script corresponding to the target binary file of the C language application, and then finds the code implementation function corresponding to the bytecode data, and calls the bytecode data. The implementation function of the code implements the function of the C language application program corresponding to the byte code.
进一步,一实施例中,所述基于C语言虚拟机的操作系统用于C语言应用程序下载、安装与运行,其中,所述C语言应用程序中编写的代码包含C语言的变量、函数、表达式和应用编程接口的字节码。Further, in one embodiment, the operating system based on the C language virtual machine is used to download, install and run a C language application program, wherein the code written in the C language application program includes variables, functions, expressions of the C language format and application programming interface bytecode.
本实施例中,所述基于C语言虚拟机的操作系统用于C语言应用程序下载、安装与运行,其中,所述C语言应用程序中编写的代码包含C语言的变量、函数、表达式和应用编程接口的字节码。所述C语言应用程序中编写的代码是根据已定义的虚拟机字节码进行编译所得的。In this embodiment, the operating system based on the C language virtual machine is used to download, install and run a C language application program, wherein the code written in the C language application program includes C language variables, functions, expressions and The bytecode of the application programming interface. The code written in the C language application program is obtained by compiling according to the defined virtual machine bytecode.
进一步,一实施例中,在所述C语言应用程序编译过程中,将所述C语言应用程序对应的函数、变量和表达式通过前端编译,生成语法树;将语法树根据已定义的虚拟机字节码进行后端编译,生成目标二进制文件。Further, in an embodiment, in the process of compiling the C language application, the functions, variables and expressions corresponding to the C language application are compiled through the front end to generate a syntax tree; the syntax tree is based on the defined virtual machine The bytecode is back-compiled to generate the target binary.
本实施例中,在所述C语言应用程序编译过程中,将所述C语言应用程序对应的函数、变量和表达式通过前端编译,生成语法树;将语法树根据已定义的虚拟机字节码进行后端编译,生成目标二进制文件。其中,所述C语言应用程序根据其用途分为应用模块、引用模块和系统模块。In this embodiment, in the process of compiling the C language application program, the functions, variables and expressions corresponding to the C language application program are compiled through the front end to generate a syntax tree; the syntax tree is based on the defined virtual machine bytes The code is back-end compiled to generate the target binary file. Wherein, the C language application program is divided into an application module, a reference module and a system module according to its purpose.
应用模块的目标二进制文件是实现了运行时环境接口的代码文件集合,操作系统可以访问并调用应用模块的运行时环境接口来执行相应的应用功能。引用模块的目标二进制文件是未实现运行时环境接口的代码文件集合,操作系统不能直接访问该模块中的方法,引用模块只能由应用模块中的方法调用。系统模块的目标二进制文件是包含各种标准应用编程接口的代码文件集合,应用开发者可以在开发时直接调用系统模块中的方法,该模块支持的应用编程接口由操作系统中的应用编程接口层提供;The target binary file of the application module is a set of code files that implement the runtime environment interface, and the operating system can access and call the runtime environment interface of the application module to execute the corresponding application function. The target binary file of the referenced module is a collection of code files that do not implement the runtime environment interface, the operating system cannot directly access the methods in the module, and the referenced module can only be called by the methods in the application module. The target binary file of the system module is a collection of code files containing various standard application programming interfaces. Application developers can directly call the methods in the system module during development. The application programming interface supported by the module is determined by the application programming interface layer in the operating system. supply;
应用模块编译生成的目标二进制文件为.SC文件、.SCCLIB文件;引用模块编译生成的目标二进制文件为.SC文件、.SCCLIB文件;系统模块生成为.SCCLIB文件。其中,.SC文件是可执行目标文件,编译器转换工具可将该二进制文件转换为GP格式的下载脚本;.SCCLIB文件是链接文件,用于编译器在编译应用模块与引用模块时进行链接使用,不会产生下载脚本。The target binary files generated by application module compilation are .SC files and .SCCLIB files; the target binary files generated by reference module compilation are .SC files and .SCCLIB files; the system modules are generated as .SCCLIB files. Among them, the .SC file is an executable object file, and the compiler conversion tool can convert the binary file into a download script in GP format; the .SCCLIB file is a link file, which is used by the compiler to link and use when compiling the application module and the reference module. , no download script will be generated.
进一步,一实施例中,所述全局平台管理层用于:Further, in one embodiment, the global platform management layer is used for:
解析下载脚本对应的C语言应用程序的目标二进制文件的结构中各个组件信息;Parse each component information in the structure of the target binary file of the C language application program corresponding to the download script;
基于操作系统中的已有数据对各个组件中需要链接的部分进行链接。The parts that need to be linked in each component are linked based on the existing data in the operating system.
本实施例中,所述全局平台管理层用于,当接收到标准GP格式的下载指令,解析下载脚本对应的C语言应用程序的目标二进制文件的结构中各个组件信息;基于操作系统中的已有数据对各个组件中需要链接的部分进行链接。链接完成后,当接收到标准GP格式的安装指令,实例化安装C语言应用程序。In this embodiment, the global platform management layer is used to, when receiving a download instruction in the standard GP format, parse each component information in the structure of the target binary file of the C language application corresponding to the download script; There is data linking the parts of each component that need to be linked. After the link is completed, when receiving the installation instruction in the standard GP format, the C language application program is instantiated and installed.
进一步,一实施例中,所述基于C语言虚拟机的操作系统还包括芯片硬件层、硬件抽象层、核心层;所述芯片硬件层由芯片硬件、固件库和算法库组成;所述硬件抽象层用于对所述芯片硬件层的固件库和算法库进行抽象封装,为操作系统提供统一的基本功能接口;所述核心层用于对所述硬件抽象层进行模块封装,使用所述硬件抽象层所提供的统一的基本功能接口,以实现操作系统中应用编程接口层、虚拟机层以及全局平台管理层的基本功能。Further, in an embodiment, the operating system based on the C language virtual machine further includes a chip hardware layer, a hardware abstraction layer, and a core layer; the chip hardware layer is composed of chip hardware, a firmware library and an algorithm library; the hardware abstraction layer is composed of The core layer is used to abstractly encapsulate the firmware library and algorithm library of the chip hardware layer, and provide a unified basic function interface for the operating system; the core layer is used to perform module encapsulation on the hardware abstraction layer, using the hardware abstraction layer. The unified basic function interface provided by the layer to realize the basic functions of the application programming interface layer, the virtual machine layer and the global platform management layer in the operating system.
本实施例中,所述基于C语言虚拟机的操作系统还包括芯片硬件层、硬件抽象层、核心层。In this embodiment, the operating system based on the C language virtual machine further includes a chip hardware layer, a hardware abstraction layer, and a core layer.
其中,所述芯片硬件层由芯片硬件、固件库和算法库组成。所述芯片硬件层搭载操作系统的SE的硬件和固件库组成,一般芯片硬件层所包含的芯片硬件是经过安全认证的芯片,经过安全认证的芯片硬件可以保证操作系统的硬件安全功能。Wherein, the chip hardware layer is composed of chip hardware, firmware library and algorithm library. The chip hardware layer is composed of the SE hardware of the operating system and the firmware library. Generally, the chip hardware included in the chip hardware layer is a chip that has passed security certification, and the chip hardware that has passed the security certification can ensure the hardware security function of the operating system.
所述硬件抽象层用于对所述芯片硬件层的固件库和算法库进行抽象封装,为操作系统提供统一的基本功能接口。在所述基于C语言虚拟机的操作系统中,所述硬件抽象层主要是提供以下基本功能接口,例如:算法接口,如DES\AES加解密功能、RSA加解密和产生密钥对功能、ECC加解密、签名验签和产生密钥对功能、sha1\sha2信息摘要功能、SM1\SM4\SM7加解密功能、SM2加解密、签名验签和产生密钥对功能、SM3信息摘要功能、产生随机数功能;通信收发接口,如ISO7816协议的初始化、接收和发送功能,ISO14443协议的初始化、接收和发送功能,SWP协议的初始化、接收和发送功能、mifare协议的初始化、接收和发送功能;系统安全接口,如芯片安全功能初始化、系统安全存储接口、系统数据安全校验接口。The hardware abstraction layer is used to abstractly encapsulate the firmware library and the algorithm library of the chip hardware layer, and provide a unified basic function interface for the operating system. In the operating system based on the C language virtual machine, the hardware abstraction layer mainly provides the following basic function interfaces, for example: algorithm interfaces, such as DES\AES encryption and decryption functions, RSA encryption and decryption and key pair generation functions, ECC Encryption and decryption, signature verification and key pair generation function, sha1\sha2 information digest function, SM1\SM4\SM7 encryption and decryption function, SM2 encryption and decryption, signature verification and key pair generation function, SM3 information digest function, random generation function Data function; communication transceiver interface, such as ISO7816 protocol initialization, reception and transmission functions, ISO14443 protocol initialization, reception and transmission functions, SWP protocol initialization, reception and transmission functions, mifare protocol initialization, reception and transmission functions; system security Interfaces, such as chip security function initialization, system security storage interface, system data security verification interface.
所述核心层用于对所述硬件抽象层进行模块封装,使用所述硬件抽象层所提供的统一的基本功能接口,以实现操作系统中应用编程接口层、虚拟机层以及全局平台管理层的基本功能。所述核心层根据应用C语言应用程序的应用编程接口要求实现如的基本功能:算法封装,主要是根据C语言应用程序的应用编程接口要求将硬件抽象层的算法接口进行统一的封装,为C语言应用程序提供各种计算模式的算法功能;APDU命令封装,在接收数据时将不同通信协议接收到的命令数据统一使用APDU格式传递给操作系统,在发送数据时将APDU数据传递给当前通信协议的发送流程;内存管理,包括NVM和RAM内存,主要是提供操作系统内存的分配、回收和记录功能;内存存储和访问功能,主要是针对NVM和RAM存储区的内存的读写功能,其中包括事务机制和普通读写功能。The core layer is used to perform module encapsulation on the hardware abstraction layer, and use the unified basic function interface provided by the hardware abstraction layer to realize the application programming interface layer, the virtual machine layer and the global platform management layer in the operating system. basic skills. The core layer implements basic functions such as: algorithm encapsulation according to the application programming interface requirements of the C language application program, mainly according to the application programming interface requirements of the C language application program. The language application program provides algorithm functions of various computing modes; APDU command encapsulation, when receiving data, the command data received by different communication protocols is uniformly transmitted to the operating system in APDU format, and the APDU data is transmitted to the current communication protocol when sending data. The sending process; memory management, including NVM and RAM memory, mainly provides operating system memory allocation, recycling and recording functions; memory storage and access functions, mainly for NVM and RAM storage area memory read and write functions, including Transaction mechanism and ordinary read and write functions.
本实施例中,提供一种基于C语言虚拟机的操作系统,所述基于C语言虚拟机的操作系统包括应用编程接口层、虚拟机层以及全局平台管理层;所述应用编程接口层用于为C语言应用程序提供应用编程接口对应的系统标准库函数;所述虚拟机层用于为C语言应用程序提供运行时环境、虚拟机解释器功能,以实现相应的C语言应用程序功能;所述全局平台管理层用于下载C语言应用程序的目标二进制文件对应的下载脚本,以及实例化安装C语言应用程序。本发明提供了一种性能更高更普适于用户的基于C语言虚拟机的操作系统,所述操作系统支持C语言应用程序下载、安装与运行,在保障了C语言应用程序的性能需求的同时,满足了C语言应用程序可以跨平台执行的需求。In this embodiment, an operating system based on a C language virtual machine is provided, and the C language virtual machine-based operating system includes an application programming interface layer, a virtual machine layer and a global platform management layer; the application programming interface layer is used for The system standard library function corresponding to the application programming interface is provided for the C language application; the virtual machine layer is used to provide the C language application with a runtime environment and virtual machine interpreter functions, so as to realize the corresponding C language application function; The global platform management layer is used to download the download script corresponding to the target binary file of the C language application, and instantiate the installation of the C language application. The present invention provides a C language virtual machine-based operating system with higher performance and more generality for users. The operating system supports the downloading, installation and running of C language application programs, while ensuring the performance requirements of C language application programs. At the same time, it satisfies the requirement that C language applications can be executed across platforms.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that, herein, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article or system comprising a series of elements includes not only those elements, It also includes other elements not expressly listed or inherent to such a process, method, article or system. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article or system that includes the element.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备执行本发明各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on such understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products are stored in a storage medium (such as ROM/RAM) as described above. , magnetic disk, optical disk), including several instructions to make a terminal device execute the method described in each embodiment of the present invention.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields , are similarly included in the scope of patent protection of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210044263.7A CN114398029A (en) | 2022-01-14 | 2022-01-14 | Operating system based on C language virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210044263.7A CN114398029A (en) | 2022-01-14 | 2022-01-14 | Operating system based on C language virtual machine |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114398029A true CN114398029A (en) | 2022-04-26 |
Family
ID=81230468
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210044263.7A Pending CN114398029A (en) | 2022-01-14 | 2022-01-14 | Operating system based on C language virtual machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114398029A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116483545A (en) * | 2023-06-19 | 2023-07-25 | 支付宝(杭州)信息技术有限公司 | Multitasking execution method, device and equipment |
CN117389691A (en) * | 2023-12-11 | 2024-01-12 | 利尔达科技集团股份有限公司 | Virtual machine based on embedded operating system |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2001009715A2 (en) * | 1999-07-28 | 2001-02-08 | Sun Microsystems, Inc. | A single-compiler architecture |
US20030192035A1 (en) * | 2002-04-09 | 2003-10-09 | Duesterwald Ald Evelyn | Systems and methods for implementing efficient execution transfers between successive translations of stack-based program code in a virtual machine environment |
US20070074191A1 (en) * | 2005-08-30 | 2007-03-29 | Geisinger Nile J | Software executables having virtual hardware, operating systems, and networks |
CN106250124A (en) * | 2016-07-25 | 2016-12-21 | 百富计算机技术(深圳)有限公司 | The implementation method of the cross-platform operation of functional module and device |
CN111880800A (en) * | 2020-06-19 | 2020-11-03 | 深圳融卡智能科技有限公司 | Application downloading method and application downloading system |
CN111880806A (en) * | 2020-07-23 | 2020-11-03 | 深圳融卡智能科技有限公司 | Application execution method and application execution system |
CN111966443A (en) * | 2019-05-20 | 2020-11-20 | 恒宝股份有限公司 | Intelligent card and working method thereof |
CN112052006A (en) * | 2020-08-12 | 2020-12-08 | 武汉天喻信息产业股份有限公司 | Software code compiling method and system |
CN113760244A (en) * | 2021-08-10 | 2021-12-07 | 武汉天喻信息产业股份有限公司 | Method and system for realizing multiple entrances and multiple interfaces based on C language mode |
-
2022
- 2022-01-14 CN CN202210044263.7A patent/CN114398029A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2001009715A2 (en) * | 1999-07-28 | 2001-02-08 | Sun Microsystems, Inc. | A single-compiler architecture |
US20030192035A1 (en) * | 2002-04-09 | 2003-10-09 | Duesterwald Ald Evelyn | Systems and methods for implementing efficient execution transfers between successive translations of stack-based program code in a virtual machine environment |
US20070074191A1 (en) * | 2005-08-30 | 2007-03-29 | Geisinger Nile J | Software executables having virtual hardware, operating systems, and networks |
CN106250124A (en) * | 2016-07-25 | 2016-12-21 | 百富计算机技术(深圳)有限公司 | The implementation method of the cross-platform operation of functional module and device |
CN111966443A (en) * | 2019-05-20 | 2020-11-20 | 恒宝股份有限公司 | Intelligent card and working method thereof |
CN111880800A (en) * | 2020-06-19 | 2020-11-03 | 深圳融卡智能科技有限公司 | Application downloading method and application downloading system |
CN111880806A (en) * | 2020-07-23 | 2020-11-03 | 深圳融卡智能科技有限公司 | Application execution method and application execution system |
CN112052006A (en) * | 2020-08-12 | 2020-12-08 | 武汉天喻信息产业股份有限公司 | Software code compiling method and system |
CN113760244A (en) * | 2021-08-10 | 2021-12-07 | 武汉天喻信息产业股份有限公司 | Method and system for realizing multiple entrances and multiple interfaces based on C language mode |
Non-Patent Citations (3)
Title |
---|
姜洪溪,黄健,葛卫清: "嵌入式实时操作系统 原理与应用研究", vol. 1, 31 December 2011, 中国原子能出版传媒有限公司, pages: 244 - 249 * |
郭荣佐,王霖主编: "嵌入式系统原理", vol. 1, 31 October 2008, 北京航空航天大学出版社, pages: 189 - 190 * |
黄翠兰: "高级语言程序设计", vol. 1, 31 July 2008, 厦门大学出版社, pages: 196 - 197 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116483545A (en) * | 2023-06-19 | 2023-07-25 | 支付宝(杭州)信息技术有限公司 | Multitasking execution method, device and equipment |
CN116483545B (en) * | 2023-06-19 | 2023-09-29 | 支付宝(杭州)信息技术有限公司 | Multitasking execution method, device and equipment |
CN117389691A (en) * | 2023-12-11 | 2024-01-12 | 利尔达科技集团股份有限公司 | Virtual machine based on embedded operating system |
CN117389691B (en) * | 2023-12-11 | 2024-03-22 | 利尔达科技集团股份有限公司 | Virtual machine based on embedded operating system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111770113B (en) | A method for executing smart contracts, blockchain node and node device | |
CN111770206B (en) | A method for deploying smart contracts, blockchain nodes and storage media | |
CN108681457B (en) | Android application program protection method based on code sinking and residual code interpretation | |
CN111770205B (en) | A method, blockchain node, system and storage medium for executing smart contracts | |
CN111815310B (en) | Method for executing intelligent contract, block chain node and storage medium | |
US20110138373A1 (en) | Method and apparatus for globally optimizing instruction code | |
CN107924326B (en) | Overriding migration methods of updated types | |
EP3961460A1 (en) | Methods, blockchain nodes and storage media for deploying smart contract | |
CN111770116B (en) | Method for executing intelligent contract, block chain node and storage medium | |
CN111768187A (en) | Method for deploying intelligent contract, block chain node and storage medium | |
CN111770204B (en) | Method for executing intelligent contract, block chain node and storage medium | |
CN111768183B (en) | Method for executing intelligent contract, block chain node and storage medium | |
CN106909441B (en) | Disk direct I/O access method based on JVM | |
CN111768184A (en) | Method for executing intelligent contract and block link point | |
CN114398029A (en) | Operating system based on C language virtual machine | |
CN111768200A (en) | Method for deploying intelligent contract, block chain node and storage medium | |
WO2025020395A1 (en) | Method for optimizing wasm bytecode, execution method, computer device and storage medium | |
CN111770202B (en) | Method for executing intelligent contract, block chain node and storage medium | |
US8601448B2 (en) | Representing pointers and boxing in environments using only reference types | |
CN110032425A (en) | A kind of dynamic link library file virtual method, system and storage medium | |
Marevac et al. | Design and Implementation of a Virtual Machine for a Dynamic Object-Oriented Programming Language | |
HK40039056A (en) | Method for executing intelligent contract, blockchain node and storage medium | |
Hyppönen et al. | Trading-off type-inference memory complexity against communication | |
HK40039057A (en) | Method for executing intelligent contract, and blockchain node | |
HK40039050A (en) | Method for executing smart contract, blockchain node and storage medium |
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 |