CN103744687B - Access method and device for input/output port - Google Patents
Access method and device for input/output port Download PDFInfo
- Publication number
- CN103744687B CN103744687B CN201310576300.XA CN201310576300A CN103744687B CN 103744687 B CN103744687 B CN 103744687B CN 201310576300 A CN201310576300 A CN 201310576300A CN 103744687 B CN103744687 B CN 103744687B
- Authority
- CN
- China
- Prior art keywords
- file
- function
- interface
- access
- input
- 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.)
- Active
Links
Landscapes
- Stored Programmes (AREA)
Abstract
The invention discloses an access method and device for an input/output port. The access method includes the steps that a device file of a current operation system is analyzed, and whether an interface device file exists in the device file of the operation system or not is judged; if not, device interface process information is added in a system kernel of the operation system, so that the device file of the operation system is prompted to have the interface device file; through a preset functional instruction, the interface device file is called to have access to the input/output port. When the operation system lacks the interface device file, the device interface progress information is added, so that the operation system is prompted to have the interface device file, a user can call the interface device file to have the access to the port through the preset functional instruction, the trouble that a mmap function, mapping and other operation need to be called to have the access to the input/output port by user space is avoided, and technical requirements are reduced for the user.
Description
Technical field
The present invention relates to computer realm, it particularly relates to a kind of access method of input/output end port and device.
Background technology
Under x86 system architecture, it will usually use the io end that x86 framework provides when in user's space access io port
Mouth access instruction in and out conducts interviews.But averagely execute speed (million instructions in single-length fixed point instruction
Per second, hereinafter referred to as mips) etc. under other system framework, there is not instruction in and out.So, just can only
Carry out io port using other modes have accessed.
Other access methods of the prior art include calling residing for io port using the mmap function fashion in c language
Address space mappinD to user's space, by the visit reaching to io port that the address in this address space is conducted interviews
Ask.But using mmap function call by the Address space mappinD at io port to user's space, need user to system tray
Structure is very familiar, clearly knows the information such as the initial address of address space at io port.The method is not suitable for primary
User.And, the method finds in use, through long system stability functional test of daring not accept.
Exist for the mode under non-x 86 system architecture, realizing in correlation technique accessing io port in user's space
Problem that is high to technical requirements of users and being unable to undergo long system stability functional test, not yet proposes effectively at present
Solution.
Content of the invention
For the problem in correlation technique, the present invention proposes a kind of access method of input/output end port and device, can
Under non-x 86 system architecture, by predetermined function command (for example, in instruction, out instruction), to access input/output terminal
Mouthful, thus avoiding the need for calling mmap function and mapping etc. to operate to realize accessing input/output end port in user's space
Trouble, reduce the technical requirements to user so that input/output end port accesses become simpler, convenient.
The technical scheme is that and be achieved in that:
According to an aspect of the invention, it is provided a kind of access method of input/output end port.
The access method of this input/output end port includes:
Whether the device file of analysis current operation system, have interface equipment literary composition in the device file of decision system
Part;
In the result judging as in the case of no, in the system kernel of operating system, add equipment interface progress information,
The device file promoting operating system possesses interface equipment file;
By predetermined function command, calling interface device file accesses corresponding input/output end port.
Wherein, by predetermined function command, when calling interface device file accesses corresponding input/output end port,
Position and the bit wide of the corresponding input/output end port of function command can be determined by analyzing predetermined function command;Further according to position
Put and bit wide, interface function corresponding with input/output end port is generated by device file;And docking port function is compiled,
Generate library file corresponding with interface function;Then by library file with containing input/output end port corresponding with function command
Application program is linked, and promotes application program to pass through the interface function in library file and accesses corresponding input/output end port.
Additionally, the access method of this input/output end port also includes: docking port function is analyzed, and determines interface function
Corresponding function declaration, function declaration is used for describing the configuration information of interface function;Function declaration is stored to being pre-configured with
In header file, and, header file is added in application program, promotees to enable applications to show the interface function in library file
Configuration information.
Wherein, function command includes in instruction and/or out instruction.
Wherein, library file includes static library file and/or dynamic library file.
According to a further aspect in the invention, there is provided a kind of access mechanism of input/output end port.
The access mechanism of this input/output end port includes:
Determination module, for analyzing the device file of current operation system, in the device file of decision system whether
There is interface equipment file;
Add module, for connecing in the case of no, adding equipment in the system kernel of operating system in result of determination
Mouth progress information, promotes the device file of operating system to possess interface equipment file;
Access modules, for by predetermined function command, calling interface device file accesses corresponding input/output terminal
Mouthful.
Wherein, access modules further include the first analysis module, generation module and first processing module, wherein, first
Analysis module, for analyzing predetermined function command, determines position and the bit wide of the corresponding input/output end port of function command;
Generation module, for according to position and bit wide, interface function corresponding with input/output end port being generated by device file, and
And, docking port function is compiled, and generates library file corresponding with interface function;First processing module, by library file with contain
The application program of input/output end port corresponding with function command is linked, and promotes application program to pass through the interface in library file
The corresponding input/output end port of function access.
And, access modules also include the second analysis module and Second processing module, wherein, the second analysis module, is used for
Docking port function is analyzed, and determines the corresponding function declaration of interface function, and function declaration is used for describing the configuration of interface function
Information;Second processing module, for storing function declaration to the header file being pre-configured with, and, header file is added to
In application program, promote the configuration information enabling applications to show the interface function in library file.
Wherein, function command includes in instruction and/or out instruction.
Wherein, library file includes static library file and/or dynamic library file.
The present invention passes through, when operating system lacks interface equipment file, to add equipment interface progress information, promotes to operate
System possesses interface equipment file, enables a user to that (for example, in instruction, out refer to by fixed in advance function command
Make) calling interface device file access port, and then avoid the need for calling mmap function and mapping etc. to operate to realize
User's space accesses the trouble of input/output end port, reduces the technical requirements of user, makes input/output end port access change
Simpler, convenient.
Brief description
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to institute in embodiment
Need use accompanying drawing be briefly described it should be apparent that, drawings in the following description be only the present invention some enforcement
Example, for those of ordinary skill in the art, on the premise of not paying creative work, can also obtain according to these accompanying drawings
Obtain other accompanying drawings.
Fig. 1 is the flow chart of the access method of input/output end port according to embodiments of the present invention;
Fig. 2 is the block diagram of the access mechanism of input/output end port according to embodiments of the present invention.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation description is it is clear that described embodiment is only a part of embodiment of the present invention, rather than whole embodiments.It is based on
Embodiment in the present invention, the every other embodiment that those of ordinary skill in the art are obtained, broadly fall into present invention protection
Scope.
According to embodiments of the invention, there is provided a kind of access method of input/output end port.
As shown in figure 1, the access method of input/output end port according to embodiments of the present invention includes:
Step s101, the device file of analysis current operation system, whether have in the device file of decision system
Interface equipment file;
Step s103, in the result judging as in the case of no, adds equipment interface in the system kernel of operating system
Progress information, promotes the device file of operating system to possess interface equipment file;
Step s105, by predetermined function command, calling interface device file accesses corresponding input/output end port.
In such scheme, when input/output end port is accessed by function command, can first analyze predetermined function command,
Determine position and the bit wide of the corresponding input/output end port of function command, and generated by device file according to this and input/output
The corresponding interface function in port, then by Compile interface function generate, corresponding library file with containing and function command pair
The application program link of the input/output end port answered, promotes application program to pass through the access of the interface function in library file corresponding
Input/output end port.
And when docking port function is analyzed, then need to determine that interface function is corresponding, for describing joining of interface function
The function declaration of confidence breath, and it is stored to the header file being pre-configured with, and promotes the application program adding this file can
The configuration information of the interface function in display library file.
In practical application, the function command in such scheme can be in instruction or out instruction, certainly,
During practical application, this function command can also be other functions instruction corresponding with current system framework.
Likewise, the library file in such scheme can be static library file or dynamic library file, user
In practical application, voluntarily can be selected according to current system architecture.
Below by way of the instantiation under Linux system environment, the technique scheme of the present invention is described in detail.
Under Linux system environment, when needing in user's space access input/output end port it is necessary first to check behaviour
Make system /dev catalogue under whether there is port device file;If there is no this file, then illustrate what operating system used
Kernel is not supported, needs to add configdevport when configuring kernel
_
Option (i.e. equipment interface progress information), to add this function, the kernel compiling out is integrated in operating system,
There is/dev/port device file after system start-up.
And in order that application program calls io port access interface function automatically, then can add in interface
In, out function, simultaneously in order to accelerate the access speed of follow-up io port, can also define the global variable of correlation representing/
The corresponding filec descriptor of dev/port device file, for example:
void init(void)__attribute__((constructor));
void destroy(void)__attribute__((destructor));
Additionally ,/dev/port device file when being initialized, can be opened by init function pair relevant environment, will
Foregoing description symbol is saved in corresponding global variable, such as fd, and close in destroy function should/dev/port sets
Standby file, to be released in the resource of application in init function.
In addition, according in, out command function, when utilization/dev/port device file realizes corresponding interface function,
Using in, out instruction, respectively certain port can be carried out with byte (8), half-word (16), word (32) conduct interviews, phase
Answer, it is possible to use in, out instruction is realized carrying out the corresponding interface function of byte, half-word, word access.
Illustrate below taking byte (8) io port read access interface function as a example.
// parameter port represents io port, and io port is normally 16, so being used herein as unsigned
Short represents;
unsigned char inb(unsigned short port)
{
// byte-accessed, definition _ v is storing the result of read access
unsigned char_v;
//fd is to represent/the global variable of dev/port device file descriptor, and lseek system calls realization by read request
Navigate to the position specified in io address space by port variable;
lseek(fd,port,seek_set);
read(fd,&_v,1);
return_v;
}
In addition, in order to preferably realize accessing io port in user's space, can also be after realizing numerous interface functions, will
Be placed in the claim set of numerous interface functions in certain file, and by realize numerous interface functions be compiled into static library or
Dynamic base, and before the compiling of application that will comprise the access of io port, then can be by the header file compiling of description interface function
The static library words becoming or dynamic base are linked.
Therefore, by the such scheme of the present invention, can be come by, out instruction under non-x 86 system architecture
Access input/output end port, thus avoiding the need for calling mmap function and mapping etc. to operate to realize visiting in user's space
Ask the trouble of input/output end port.
According to embodiments of the invention, additionally provide a kind of access mechanism of input/output end port.
As shown in Fig. 2 the access mechanism of input/output end port according to embodiments of the present invention includes:
Determination module 21, for analyzing the device file of current operation system, in the device file of decision system be
No have interface equipment file;
Add module 22, in the case of being no in the result of determination of determination module 21, into the system of operating system
Add equipment interface progress information in core, promote the device file of operating system to possess interface equipment file;
Access modules 23, for by predetermined function command, calling add module 22 to promote connecing of operating system interpolation
The corresponding input/output end port of jaws equipment file access.
Wherein, access modules 23 further include the first analysis module (not shown), generation module (not shown) and first
Processing module (not shown), wherein, the first analysis module (not shown), for analyzing predetermined function command, determine that function refers to
Make position and the bit wide of corresponding input/output end port;Generation module (not shown), for (not showing according to the first analysis module
Go out) defined location and bit wide, interface function corresponding with input/output end port is generated by device file, and, docking port
Function is compiled, and generates library file corresponding with interface function;First processing module (not shown), generation module (is not shown
Go out) library file that generates with containing the application program of corresponding input/output end port is linked with function command, promote application journey
The interface function that sequence is passed through in library file accesses corresponding input/output end port.
And, access modules 23 also include the second analysis module (not shown) and Second processing module (not shown), wherein,
Second analysis module (not shown), the interface function for generating to generation module (not shown) is analyzed, and determines interface letter
The corresponding function declaration of number, function declaration is used for describing the configuration information of interface function;Second processing module (not shown), is used for
The function declaration that second analysis module (not shown) is determined stores to the header file being pre-configured with, and, by header file plus
Enter in application program, promote the configuration information enabling applications to show the interface function in library file.
In practical application, the function command in such scheme can be in instruction or out instruction, certainly,
During practical application, this function command can also be other functions instruction corresponding with current system framework.
Likewise, the library file in such scheme can be static library file or dynamic library file, user
In practical application, voluntarily can be selected according to current system architecture.
In sum, by means of the technique scheme of the present invention, by operating system lack interface equipment file when,
Add equipment interface progress information, promote operating system to possess interface equipment file, enable a user to by fixed in advance
Function command (for example, in instruction, out instruction) calling interface device file access port, and then avoid the need for calling
Mmap function and mapping etc. operate to be realized accessing the trouble of input/output end port in user's space, reduces the skill of user
Art requires, and makes input/output end port access the simpler, convenient of change.
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all essences in the present invention
Within god and principle, any modification, equivalent substitution and improvement made etc., should be included within the scope of the present invention.
Claims (8)
1. a kind of access method of input/output end port is it is characterised in that include:
Whether the device file of analysis current operation system, have interface equipment literary composition in the device file judging described operating system
Part;
In the result judging as in the case of no, in the system kernel of described operating system, add equipment interface progress information,
The device file promoting described operating system possesses interface equipment file;
By predetermined function command, call the corresponding input/output end port of described interface equipment file access;
Wherein, by predetermined function command, the corresponding input/output end port of described interface equipment file access is called to include:
Analyze predetermined function command, determine position and the bit wide of the corresponding input/output end port of described function command;
According to described position and bit wide, by described interface equipment file generated interface corresponding with described input/output end port
Function;And, described interface function is compiled, generates library file corresponding with described interface function;
Described library file is linked with the application program containing input/output end port corresponding with described function command, is promoted
Make described application program pass through the described interface function in described library file and access corresponding described input/output end port.
2. access method according to claim 1 is it is characterised in that further include:
Described interface function is analyzed, determines the corresponding function declaration of described interface function, described function declaration is used for retouching
State the configuration information of described interface function;
Described function declaration is stored to the header file being pre-configured with, and, described header file is added to described application journey
In sequence, promote described application program can show the configuration information of the described interface function in described library file.
3. the access method according to claim 1 to 2 any one it is characterised in that described function command include following
At least one:
In instruction, out instruction.
4. access method according to claim 2 is it is characterised in that described library file includes at least one of:
Static library file, dynamic library file.
5. a kind of access mechanism of input/output end port is it is characterised in that include:
Whether determination module, for analyzing the device file of current operation system, judge in the device file of described operating system
There is interface equipment file;
Add module, for connecing in the case of no, adding equipment in the system kernel of described operating system in result of determination
Mouth progress information, promotes the device file of described operating system to possess interface equipment file;
Access modules, for by predetermined function command, calling the corresponding input/output terminal of described interface equipment file access
Mouthful;
Wherein, described access modules further include the first analysis module, generation module and first processing module, wherein,
First analysis module, for analyzing predetermined function command, determines the corresponding input/output end port of described function command
Position and bit wide;
Generation module, for according to described position and bit wide, by described interface equipment file generated and described input/output terminal
The corresponding interface function of mouth, and, described interface function is compiled, generate library file corresponding with described interface function;
First processing module, by described library file and the application program containing the corresponding input/output end port with described function command
Linked, promote described application program to pass through the interface function in described library file and access corresponding input/output end port.
6. access mechanism according to claim 5 it is characterised in that described access modules also include the second analysis module and
Second processing module, wherein,
Second analysis module, for being analyzed to described interface function, determines the corresponding function declaration of described interface function, institute
State function declaration for describing the configuration information of described interface function;
Second processing module, for storing described function declaration to the header file being pre-configured with, and, by described header file
It is added in described application program, promote described application program can show the configuration of the described interface function in described library file
Information.
7. the access mechanism according to claim 5 to 6 any one it is characterised in that described function command include following
At least one:
In instruction, out instruction.
8. access mechanism according to claim 6 is it is characterised in that described library file includes at least one of:
Static library file, dynamic library file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310576300.XA CN103744687B (en) | 2013-11-15 | 2013-11-15 | Access method and device for input/output port |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310576300.XA CN103744687B (en) | 2013-11-15 | 2013-11-15 | Access method and device for input/output port |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103744687A CN103744687A (en) | 2014-04-23 |
CN103744687B true CN103744687B (en) | 2017-01-25 |
Family
ID=50501707
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310576300.XA Active CN103744687B (en) | 2013-11-15 | 2013-11-15 | Access method and device for input/output port |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103744687B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104123194A (en) * | 2014-07-16 | 2014-10-29 | 上海斐讯数据通信技术有限公司 | Communication structure and method for kernel mode and user mode |
CN107315607B (en) * | 2017-06-21 | 2020-05-05 | 南京翼辉信息技术有限公司 | Drive self-adaptation loading system |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102232304A (en) * | 2011-05-04 | 2011-11-02 | 华为终端有限公司 | Method, system and terminal for system update between mobile communication terminals |
CN102508760A (en) * | 2011-11-17 | 2012-06-20 | 浪潮(北京)电子信息产业有限公司 | Early warning method for redundant array of independent disks (RAID) and early warning system for RAID |
-
2013
- 2013-11-15 CN CN201310576300.XA patent/CN103744687B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102232304A (en) * | 2011-05-04 | 2011-11-02 | 华为终端有限公司 | Method, system and terminal for system update between mobile communication terminals |
CN102508760A (en) * | 2011-11-17 | 2012-06-20 | 浪潮(北京)电子信息产业有限公司 | Early warning method for redundant array of independent disks (RAID) and early warning system for RAID |
Non-Patent Citations (2)
Title |
---|
"IO端口和IO内存的区别及分别使用的函数接口";alan00000;《http://blog.csdn.net/alan00000/article/details/8649952》;20130308;全文 * |
"Linux内核驱动之自动创建设备文件";wenyubo_2008;《http://blog.chinaunix.net/uid-25968088-id-3287168.html》;20120725;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN103744687A (en) | 2014-04-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109885311B (en) | Application program generation method and device | |
US10862979B2 (en) | Techniques for supporting remote micro-services as native functions in spreadsheet applications | |
CN106547527B (en) | JavaScript file construction method and device | |
CN108091384B (en) | Medical image processing system based on micro-service framework | |
CN105814539A (en) | Method and apparatus for code virtualization and remote process call generation | |
US11048885B2 (en) | Cognitive translation service integrated with context-sensitive derivations for determining program-integrated information relationships | |
US11157533B2 (en) | Designing conversational systems driven by a semantic network with a library of templated query operators | |
CN106326099B (en) | A kind of method, apparatus and electronic equipment for program tracking | |
CN113805882A (en) | Method and device for developing application program, electronic equipment and storage medium | |
CN103744687B (en) | Access method and device for input/output port | |
US20150106796A1 (en) | Class loading device for a java runtime environment, cluster system and method of executing a function | |
CN114048415A (en) | Form generation method and device, electronic equipment and computer readable storage medium | |
CN113778897A (en) | Automatic test method, device, equipment and storage medium of interface | |
CN112015374B (en) | Cross-programming-language micro-service integration system based on natural language | |
WO2022099913A1 (en) | Interface configuration method and apparatus, and device and medium | |
CN111488286B (en) | Method and device for independently developing Android modules | |
CN114064176A (en) | View interaction method and device, electronic equipment and computer readable medium | |
CN115769191A (en) | Managing asynchronous operations in a cloud computing environment | |
CN113761588A (en) | Data verification method and device, terminal equipment and storage medium | |
CN112650502A (en) | Batch processing task processing method and device, computer equipment and storage medium | |
Heil et al. | DCM: dynamic client-server code migration | |
CN106484489A (en) | A kind of method and device of extension programming language characteristic | |
CN112068814A (en) | Method, device, system and medium for generating executable file | |
CN113608726B (en) | Code generation method, device, electronic equipment and storage medium | |
CN112988260B (en) | Application cold start optimization method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220725 Address after: 100089 building 36, courtyard 8, Dongbeiwang West Road, Haidian District, Beijing Patentee after: Dawning Information Industry (Beijing) Co.,Ltd. Patentee after: DAWNING INFORMATION INDUSTRY Co.,Ltd. Address before: 100193 No. 36 Building, No. 8 Hospital, Wangxi Road, Haidian District, Beijing Patentee before: Dawning Information Industry (Beijing) Co.,Ltd. |
|
TR01 | Transfer of patent right |