The 0414__linux of Linux Learning

Source: Internet
Author: User

In general, whether C, C + + or PAS, the first to compile the source file into an intermediate code file,
Under Windows is the. obj file, and under UNIX is. o file, that is, objuct file, this action
is called compilation (compile).


Device Drivers act as a link between hardware and application software that allows applications to invoke only the system
The application Programming Interface (API) of the software allows the hardware to perform the required work.


In the absence of an operating system, an agent can define its own interface.


In the case of an operating system, the device-driven architecture has a corresponding operating system definition, which drives the engineer
Device drivers must be designed according to the appropriate architecture, so that device drivers can be well integrated into the operating system's
The kernel.


The application can access a variety of character devices and block devices by reading and writing files via write (), read () functions, and so on.
Instead of the specific type of equipment and working methods.


Linux divides memory and peripherals into 3 basic categories:
Character devices
Block device
Network equipment


Character Devices:
Refers to devices that must be accessed sequentially in sequential order, such as touch screens, tape drives, mice, and so on.


Block device:
can be accessed in any order, in block units, such as hard disk, floppy drive, and so on.


Character devices do not pass the fast buffering of the system, and block devices are quickly buffered by the system.
However, character devices and block devices do not have significant boundaries, such as flash equipment conforming to the characteristics of the block device,
But we can still access it as a character device.






In addition to network devices, character devices and block devices are mapped to the Linux file system
Files and directories, and functions such as the system call Interface open (), write (), read (), close (), and so on file system
Access to character devices and block devices


Applications can be programmed using Linux system invoke interfaces, or C library functions, for code
Portability of consideration, the latter more worthy of recommendation. The C library function itself is also implemented through the system call interface, such as C
The fopen (), fwrite (), Fread (), fclose () in the library function invoke the open (), write () of the operating system API, respectively.
Read (), close () function.


LED driver under Linux system


Light_init () light_on () Light_off ()
These functions are called by the device-independent interface for the LED driver.


struct LIGHT_DEV
{
struct Cdev Cdev;
unsigned char value;
}


struct Light_dev *light_devp;


int Light_open (struct inode *inode, struct file *filp)


int light_release (struct inode *inode, struct file *filp)


ssize_t light_read (struct file *filp, char _ _user *buf, size_t count, Loff_t*f_pos)


ssize_t light_write (struct file *filp, const char _ _user *buf, size_t count, loff_t *f_pos)


int Light_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)


struct File_operations light_fops =
{
. Owner = This_module,
. Read = Light_read,
. write = Light_write,
. IOCTL = Light_ioctl,
. open = Light_open,
. Release = Light_release,
};


static void Light_setup_cdev (struct light_dev *dev, int index)
/* Device character device Cdev structural body * *
static void Light_setup_cdev (struct light_dev *dev, int index)
/* Module Load function * *
int light_init (void)
/* Allocate the memory of the structure of the device * *
LIGHT_DEVP = kmalloc (sizeof (struct light_dev), gfp_kernel);
/* Module Unload function * *
void Light_cleanup (void)




The system architecture of the central processing unit can be divided into two categories, one is von Neumann structure, the other is the Harvard structure.
Von. Neumann structure:
Also known as the Princeton structure, is a memory structure that combines program instruction memory with data memory.
The program instruction stores the address and the data store address to the different physical locations of the same memory, so the program instruction is the same width as the data.


The Harvard structure stores the program instructions and data separately, and the instruction and data can have different data widths.
In addition, the Harvard structure also uses a separate program bus and data bus, respectively, as the CPU and each memory of the dedicated communication path,
has higher instruction efficiency.


The central processing unit can also be divided into two categories, namely RISC (compact instruction set computer) and CISC (complex instruction set computer).
CSIC emphasizes the ability to increase instructions and reduce the number of target code, but the instructions are complex and the instruction cycle is long
And RISC emphasizes minimizing instruction set, instruction single cycle execution,
But the target code will be larger. The CPU kernel of ARM, MIPS and PowerPC all adopt RISC instruction set.
At present, the fusion of RISC and CSIC is very obvious.


The Ethernet interface consists of a MAC (Ethernet media access Controller) and PHY (physical interface transceiver).
A MII (media independent interface) connection is used between Mac and PHY.

































Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.