Embedded system software memory expansion method based on MIPS architecture
By mapping and managing memory management units on MIPS processors, the memory limited problem caused by address space segmentation of MIPS processors is solved, and the memory space is expanded to meet the needs of complex embedded system software for larger memory space.
Patent Information
- Application Number
- CN202411810219.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-15
AI Technical Summary
The address space segmentation of the MIPS processor results in limited actually accessible memory space, limiting the need for larger stack space by complex embedded system software.
By determining the spatial range and purpose of the processor's fixed mapping, memory management unit (MMU) mapping and management are carried out, and the program address space mapped by MMU is registered with the reserved segment of the operating system to expand the memory space.
It realizes the expansion of memory space on the MIPS processor, meets the needs of complex embedded system software for larger memory space, and supports the stable operation of upper-level applications.
Smart Images

Figure CN119829474A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of embedded computer system software, and in particular provides an embedded system software memory expansion method based on a MIPS architecture. Background Art
[0002] The use and processing of address space by MIPS processors is different from that of traditional CPUs. One obvious point is that the mapping between virtual addresses and physical addresses of other CPUs can be transparent, that is, one-to-one mapping, while MIPS processors, under 32-bit addressing, divide the space into four areas by default, kseg2, kseg1, kseg0, and kuseg. Different areas require different processing. Figure 2 As shown in the figure, the address range of kuseg is 0x0000_0000-0x7FFF_FFFF (low-end 2GB), which is an address available in user mode, but needs to be converted by MMU. The address range of kseg0 is 0x8000_0000-0x9FFF_FFFF (512MB). This address area clears the highest bit and is fixedly mapped to the continuous low-end address under the physical address, that is, 0x0000_0000-0x1FFF_FFFF. This part of the address needs to be accessed through the cache and is generally used to store the operating system core. The address range of kseg1 is 0xA000_0000-0xBFFF_FFFF (512MB). This address area maps the physical address by clearing the highest three bits to zero, and repeatedly maps it to the low-end 512MB physical address. However, this area does not pass through the cache, that is, kseg1 is the only address space that can work normally when the system is restarted. Therefore, the entry point (0xBFC0_0000) at reset is placed in this area. The address range of kseg2 is 0xC000_0000-0xFFFF_FFFF (1GB). This address area can only be used in kernel mode and needs to be converted by MMU.
[0003] The biggest impact of regional division is that the address space is not continuous, which leads to limited actually accessible memory space. For simple embedded software, only the addresses of kseg0 and kseg1 may be used. However, for complex embedded systems, when a larger stack space is required, insufficient memory will occur, which seriously limits the operation of the application. How to expand the memory space of the MIPS processor is a problem worth studying for embedded system software. Summary of the invention
[0004] The purpose of this application is to expand the continuous memory space under the condition that the MIPS processor segments the address space, meet the demand of complex embedded system software for a larger memory space, and support the stable operation of upper-level applications.
[0005] In order to achieve the above object, the present invention adopts the following technical solution: a method for extending the software memory of an embedded system based on the MIPS architecture, the method comprising:
[0006] Determine the address area where memory expansion can be performed based on the fixed mapping space range and usage of the processor;
[0007] Map and manage the address space that needs to be expanded for use by the memory management unit;
[0008] The program address space mapped by the memory management unit is registered to the reserved segment of the operating system for use.
[0009] The embedded system software memory expansion method based on the MIPS architecture provided by the present invention also has the following technical features: the processor fixed mapping includes the fixed mapping required by the MIPS architecture itself and the fixed design and mapping of the processor itself.
[0010] The embedded system software memory expansion method based on the MIPS architecture provided by the present invention also has the following technical features: mapping and managing the address space to be expanded for use by the memory management unit includes:
[0011] According to actual application requirements, multiple physically discontinuous address spaces are configured as memory management units.
[0012] The embedded system software memory expansion method based on the MIPS architecture provided by the present invention also has such a technical feature that the processor fixed mapping space includes:
[0013] User-mode address space is the application access space when the operating system is running;
[0014] The operating system kernel space is used to store the operating system kernel program and data to run the operating system;
[0015] The operating system boot space is the memory space used to perform basic hardware initialization on the CPU processor when the system is powered on; and
[0016] Kernel space: kernel space used when the system is in supervisor mode.
[0017] The embedded system software memory expansion method based on the MIPS architecture provided by the present invention also has the following technical features: when the program address space mapped by the memory management unit is registered to the operating system, the segmented address space is registered and managed separately.
[0018] Beneficial Effects
[0019] The embedded system software memory expansion method based on the MIPS architecture provided by the present invention solves the problem of limited continuous memory caused by the fixed mapping of the MIPS processor, and can meet the requirements of complex embedded system software for a larger stack space. The method is cleverly designed, flexible in implementation, easy to operate, and can be widely used in the field of embedded system software. The method has significant advantages when the embedded system software is transplanted from the architectures such as PowerPC and ARM to the MIPS architecture, and can stably support the application operation without affecting the application performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 A flowchart of the method provided by the present invention;
[0022] Figure 2 This is a schematic diagram of the MIPS processor space mapping;
[0023] Figure 3 This is a schematic diagram of the LS2K1000 processor space mapping. DETAILED DESCRIPTION
[0024] The present application is further described in detail below in conjunction with the accompanying drawings and examples, but it should be noted that these implementation methods are not limitations of the present application, and equivalent changes or substitutions in functions, methods, or structures made by ordinary technicians in the field based on these implementation methods are all within the scope of protection of the present application.
[0025] In the description of the embodiments of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the creation of the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the creation of the present application.
[0026] In addition, the terms "first", "second", "third", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the invention of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0027] The terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the invention of this application can be understood by specific circumstances.
[0028] like Figure 1-3 As shown, an embodiment of the present application provides an embedded system software memory expansion method based on the MIPS architecture, the method comprising:
[0029] Determine the address area where memory expansion can be performed based on the fixed mapping space range and usage of the processor;
[0030] Map and manage the address space that needs to be expanded for use by the memory management unit;
[0031] The program address space mapped by the memory management unit is registered to the reserved segment of the operating system for use.
[0032] In some embodiments, the processor fixed mapping includes the fixed mapping required by the MIPS architecture itself and the fixed design and mapping of the processor itself.
[0033] In some embodiments, mapping and managing the address space to be expanded for use by the memory management unit includes:
[0034] According to actual application requirements, multiple physically discontinuous address spaces are configured for memory management units. Selecting discontinuous address spaces for MMU mapping and management improves space utilization and provides greater dynamic space support for application operation.
[0035] In some embodiments, the processor fixed mapping space includes:
[0036] User-mode address space is the application access space when the operating system is running. It must be mapped and managed by the memory management unit MMU before use.
[0037] The operating system kernel space is used to store the operating system kernel program and data to run the operating system. Its access does not require mapping but is cached through the memory cache;
[0038] The operating system boot space is the memory space used to perform basic hardware initialization on the CPU processor when the system is powered on. This address space does not need to be mapped and does not pass through the memory cache; and
[0039] Kernel state space, the kernel space used when the system is in supervisory mode. This address space can only be used in kernel state and needs to be mapped by MMU.
[0040] In some embodiments, when the program address space mapped by the memory management unit is registered to the operating system, the segmented address space is registered and managed separately, and the address space is reserved for use by the operating system.
[0041] In some embodiments, the memory expansion of Loongson Technology's MIPS processor LS2K1000 under the Tianmai 1 operating system is taken as an example for further detailed description. The development environment used in this embodiment is LambdaAE.
[0042] The Tianmai 1 airborne embedded real-time operating system (Tianmai 1 for short) has the characteristics of strong real-time performance, support for system customization and configurability, and has been widely used.
[0043] The LS2K1000 processor is mainly oriented to network applications, taking into account tablet applications and industrial control applications. The routing of the Loongson 2K1000 is mainly composed of the system's two-level crossbar switch and IO sub-network. The routing of the first-level switch is not configurable, and the specific space (physical) allocation is shown in Table 1.
[0044] Table 1 Level 1 crossbar switch routing rules
[0045]
[0046] 1. Clearly define the expandable space
[0047] According to the characteristics of the MIPS processor and the routing characteristics of the LS2K1000, the spatial division of the LS2K1000 processor is shown as follows: Figure 3, we can see that the kseg0 and kseg1 space ranges are fixedly mapped, the program address 0x8000_0000-0x9000_0000 is mapped to the physical address 0x0000_0000-0x1000_0000, this part of the space has cache attributes, is the zero address of the memory, the memory size is 256MB, and the program address 0xB000_0000-0xC000_0000 is mapped to the physical address 0x1000_0000-0x2000_0000 for register configuration or as a startup space, etc. In addition, in Table 1, LS2K1000 divides the physical address 0x4000_0000-0x7FFF_FFFF into IO attributes in the address space, which has a certain purpose and should not be allocated again.
[0048] Judging from the entire physical space range (the gray part is unavailable, addresses 0x8000_0000 and 0x0000_0000 both point to the zero address of the memory), the remaining expandable space range is above the high address 0x9000_0000.
[0049] 2. MMU mapping of the extended space
[0050] After clarifying the address space that can be expanded to memory, create an MSL project and configure the space. For simplicity, transparently map the program address 0x4000_0000-0x7FFF_FFFF to the physical address 0x4000_0000-0x7FFF_FFFF and use it as IO space. Map the program address 0x0000_0000-0x0FFF_FFFF to the physical address 0x0000_0000-0x0FFF_FFFF, which is consistent with the usage habits of other architecture memory. Taking the expansion of 512MB memory space as an example, map the program address 0x1000_0000-0x2FFF_FFFF to the continuous physical space 0x9000_0000-0xAFFF_FFFF, set the space attribute to memory space, and this segment of space will be used as the second segment of memory space. The first segment of memory space is the space pointed to by the program address 0x8000_0000, which is 256MB in size. If there is a larger memory requirement, the remaining available space can be mapped in segments.
[0051] 3. Management and use of expansion space
[0052] Create an OS project. The OS project includes a RAM partition by default in the memory configuration, which is used to run the operating system core. Because the MIPS architecture places the operating system in the kseg0 segment by default, that is, the area pointed to by the program address 0x8000_0000, the continuous memory space size is only 256MB. In order to expand the memory space, a new partition needs to be created for memory configuration. The new partition needs to set the partition name, starting address and partition size. According to the above instructions, the starting address is set to 0x1000_0000, the partition size is 0x2000_0000, corresponding to the physical address 0x9000_0000-0xAFFF_FFFF, and the partition name is set to os_heap. At the same time, create a new reserved segment in the partition os_heap and modify the parameters of the segment, including setting the starting address and segment size, etc. This segment will be used for dynamic allocation of memory.
[0053] After creating the os_heap partition, the operating system will manage and initialize its space during the OS initialization process. This function is implemented by the sysHeapInitialize function. Note that this operation must be performed after enabling the MMU and performing MMU mapping. In this way, the expanded memory space can be used normally.
[0054] The above is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application. The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and variations can be made without departing from the technical principles of the present application, and these improvements and variations should also be regarded as the protection scope of the present application.
Claims
1. A method for extending the software memory of an embedded system based on the MIPS architecture, characterized in that: The method comprises: Determine the address area where memory expansion can be performed based on the fixed mapping space range and usage of the processor; Map and manage the address space that needs to be expanded for use by the memory management unit; The program address space mapped by the memory management unit is registered to the reserved segment of the operating system for use.
2. The method for extending the software memory of an embedded system based on the MIPS architecture according to claim 1, characterized in that: The processor fixed mapping includes the fixed mapping required by the MIPS architecture itself and the fixed design and mapping of the processor itself.
3. The method for extending the software memory of an embedded system based on the MIPS architecture according to claim 1, characterized in that: The memory management unit mapping and management of the address space to be expanded includes: According to actual application requirements, multiple physically discontinuous address spaces are configured as memory management units.
4. The method for extending the software memory of an embedded system based on the MIPS architecture according to claim 1, characterized in that: The processor's fixed mapping space includes: User-mode address space is the application access space when the operating system is running; The operating system kernel space is used to store the operating system kernel program and data to run the operating system; The operating system boot space is the memory space used to perform basic hardware initialization on the CPU processor when the system is powered on; as well as Kernel space: kernel space used when the system is in supervisor mode.
5. The method for extending the software memory of an embedded system based on the MIPS architecture according to claim 1, characterized in that: When the program address space mapped by the memory management unit is registered to the operating system, the segmented address space segments are registered and managed separately.
Citation Information
Patent Citations
MIPS platform-oriented memory virtualization method
CN102567217A
Memory management method and apparatus
CN107025180A
Method and device for expanding MIPS instruction set processor to support RISC instruction set multimode system
CN114077424A