⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 199.htm

📁 pcb设计资料初学者难得的入门资料包含工厂制作过程
💻 HTM
📖 第 1 页 / 共 3 页
字号:


InterruptControllerGetPendingIntVector(&intvector); <br>

InterruptControllerGetPendingIntSrc((&irq); <br>

action = (struct irqaction *)intvector; <br>

if ( action == NULL ) { <br>

   printk(*No handler for hw0 irq: %i\n*, irq); <br>

return; <br>

} <br>

hardirq_enter(cpu); <br>

action->handler(irq, action->dev_id, regs); <br>

kstat.irqs[0][irq]++; <br>

hardirq_exit(cpu); <br>

} // InterruptController_InterruptHandler () <br>

The functions request_irq(), free_irq(), enable_irq() and disable_irq() have <br>

 to be implemented for your target platform. request_irq() is used to instal <br>

l an interrupt handler for a given interrupt source. free_irq() needs to fre <br>

e the memory allocated for the given interrupt. enable_irq() needs to make a <br>

 call to the interrupt controller function that enables the given interrupt <br>

line and disable_irq() needs to disable the given interrupt line. <br>

Timer interrupt <br>

File $(TOPDIR)/arch/MY_ARCH/MY_PLATFORM/time.c contains the platform-depende <br>

nt timer code. The Linux kernel on MIPS requires a 100Hz timer interrupt. In <br>

 the MIPS, one of the timers in coprocessor 0 is programmed to generate 100H <br>



z interrupts. The count register and the compare register together make up t <br>

he timer. When active, the count register contains a free running counter. O <br>

n each processor clock-tick, the value in the register increments by one. Th <br>

e register is reset and an external hardware interrupt is generated when the <br>

 values in the count register and compare register match. After the count re <br>

gister is reset, it restarts to count on the next processor clock-tick. The <br>

timer interrupt service routine (ISR) needs to call the do_timer() routine. <br>

Performing a write to the compare register clears the timer interrupt. <br>

Serial console driver <br>

The console runs on top of a serial driver. A polled serial driver can be us <br>

ed for printk() (kernel debug message) functionality. The minimum functions <br>

that this driver needs to provide are the following: <br>

serial_console_init()-for registering the console printing procedure for ker <br>

nel printk() functionality, before the console driver is properly initialize <br>

d <br>

serial_console_setup()-for initializing the serial port <br>

serial_console_write(struct console *console, const char *string, int count) <br>

-for writing "count" characters <br>

Hook up the serial port on your development board to your host development p <br>

latform, then start up a serial communication program on your host developme <br>

nt platform to communicate with your target. <br>

tty driver <br>

tty driver <br>

An interrupt driven serial driver can be used to create a terminal device. A <br>

 terminal device can be created by registering the serial driver with tty. A <br>

 variety of serial drivers are available in the $(TOPDIR)/drivers/char direc <br>

tory. The driver that matches closest to the serial port hardware being used <br>

 should be picked up and modified. The interfaces to an interrupt-driven cha <br>

racter driver under Linux have been explained in Linux Device Drivers by Rub <br>

ini (see References). <br>

CONFIG_SERIAL (serial support) has to be defined as Y in "make config." To t <br>

est, hook up the interrupt-driven serial port to the host development platfo <br>

rm and run a serial communication program to communicate with your target (t <br>

erminal device). <br>

Bootloader <br>

Although LILO (the Linux loader) should be available for your architecture, <br>

it may be quicker to use your own bootloader to load the Linux kernel. [4] L <br>

ILO passes some information to the kernel in a way similar to how an Intel P <br>

C BIOS passes information to the kernel. LILO then calls the "kernel_entry" <br>

function inside the kernel, giving up control to the kernel. If you're using <br>

 your own bootloader, you need to pass parameters to the kernel by adding th <br>

em to the "command_line" string, which is parsed by the kernel. In my case, <br>

I had to add "root=/dev/ram" to the command_line string to tell the kernel t <br>

hat I wanted the ramdisk to be mounted as the root file system. You could ad <br>

d other kernel parameters to this string, if needed. Load the image at the s <br>



pecified load address using your bootloader. Start executing from the addres <br>

s of the "kernel_entry" symbol in the kernel image. <br>

It will be easier to debug if the bootloader had its own "print" function, b <br>

ecause the printk function inside the kernel buffers all the output to the c <br>

onsole until the console is initialized (console_init() in $(TOPDIR)/init/ma <br>

in.c). <br>

If everything goes well, you should get something like the following message <br>

 on your kernel debug terminal: <br>

Detected 32MB of memory. <br>

Loading R4000/MIPS32 MMU routines. <br>

CPU revision is: 000028a0 <br>

Primary instruction cache 32 kb, linesize 32 bytes <br>

Primary data cache 32 kb, linesize 32 bytes <br>

Linux version 2.2.12 (rpalani@rplinux) <br>

(gcc version egcs-2.90.29 980515 (egcs-10)) <br>

CPU frequency 200.00 MHz <br>

Calibrating delay loop: 199.88 BogoMIPS <br>

Memory: 14612k/16380k available <br>

(472k kernel code, 908k data) <br>

Checking for 鍂ait' instruction...  available. <br>

POSIX conformance testing by UNIFIX <br>

Linux NET4.0 for Linux 2.2 <br>



Based upon Swansea University Computer Society NET3.039 <br>

Starting kswapd v1.1.1.1 <br>

No keyboard driver installed <br>

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize <br>

RAMDISK: Compressed image found at block 0 <br>

VFS: Mounted root (ext2 filesystem) readonly. <br>

Freeing unused kernel memory: 32k freed <br>

The kernel tries to open a console and find and execute "init" from one of t <br>

he following places in the root file system, in sequence: /sbin/init, /etc/i <br>

nit, /bin/init. If all the above fail, it tries to create an interactive she <br>

ll (/bin/sh as happens in my case). If even this fails, then the kernel "pan <br>

ics," as would you. I hope that this does not happen in your case. If it doe <br>

sn't a shell prompt will appear on the console. Applications can be run on t <br>

he system by dropping them inside the ramdisk image and executing from there <br>

. <br>

Adding new drivers <br>

New drivers for your target hardware can be added by picking up the driver t <br>

hat matches most closely to your hardware (a vast number are available) and <br>

modifying it. If you are dealing with a proprietary piece of hardware that i <br>

s specific to your system, use the standard driver interfaces to implement a <br>

 driver for the same. These drivers can be implemented as kernel modules in <br>

order to load and unload them using insmod and rmmod. <br>



Useful tips <br>

Sprinkle printk() statements liberally throughout your code to aid debugging <br>

. This may be an obvious suggestion, but it is worth mentioning. Remote GDB <br>

[5] may also be useful for debugging, though in my experience printk's are m <br>

ore than enough for debugging kernel code. In remote GDB, the host developme <br>

nt system runs gdb and talks to the kernel running on the target platform vi <br>

a a serial line. You need to setup CONFIG_REMOTE_DEBUG = Y in the kernel con <br>

figuration. putDebugChar(char ch) and getDebugChar() are the two functions t <br>

hat need to be implemented over the serial port for remote debugging using g <br>

db. <br>

If you are forced to use a common port for console and debug, the GDB output <br>

 can be multiplexed with the debug output by setting the high bit in putDebu <br>

gChar(). GDB forwards output without the high bit set to the user session. <br>

To start with, implement only the basic minimum functions for the tty driver <br>

 as specified in $(TOPDIR)/include/linux/tty_ldisc.h. <br>

Real-time requirements <br>

The subject of embedded systems is not complete without a mention of real-ti <br>

me requirements. The standard Linux kernel provides soft real-time support. <br>

There are currently two major approaches to achieve hard real-time with Linu <br>

x. These are RTLinux and RTAI. Both approaches have their own real-time kern <br>

el running Linux as the lowest priority task. When dealing with proprietary <br>

hardware, as it often happens in embedded systems, the issue of proprietary <br>



software crops up as well. In Linux, proprietary modules can be handled with <br>

 the GNU Lesser General Public License, which permits linking with non-free <br>

modules. It is compatible with the GNU General Public License, which is a fr <br>

ee software license, and a copyleft license. [6] <br>

With a good knowledge of the processor architecture and the hardware devices <br>

 being used, porting Linux to an embedded system can be accomplished in a sh <br>

ort time frame, which is of vital importance in the fast paced embedded syst <br>

ems market. In my case, where I have been using UNIX for quite some time, it <br>

 took me around two months to complete the port of the minimum kernel functi <br>

onality to our platform. Porting Linux to a different platform should not ta <br>

ke that long when doing it for a second time. <br>

Rajesh Palani works as a senior software engineer at Philips Semiconductors. <br>

 He has been designing and developing embedded software since 1993. He has w <br>

orked on the design and development of software (ranging from firmware to ap <br>

plications) for set-top boxes, digital still cameras, TVs (Teletext), and an <br>

tilock braking systems. Contact him at rajesh.palani@philips.com. <br>

Endnotes <br>

1. Stands for "GNU's Not Unix," a project launched in 1984 to develop a comp <br>

lete Unix-like operating system which is free software: the GNU system. <br>

Back <br>

2. The topmost directory in the Linux source tree (/usr/src/linux, by defaul <br>

t). <br>

t). <br>

Back <br>

3. Translation Lookaside Buffer-hardware used for virtual to physical addres <br>

s mapping in a processor. <br>

Back <br>

4. The subject of developing a bootloader for your processor is outside the <br>

scope of this article. <br>

Back <br>

5. GNU Debugger-helps you to start your program, make it stop on specified c <br>

onditions, examine what has happened (when your program has stopped), and ch <br>

ange things in your program. <br>

Back <br>

6. Copyleft says that anyone who redistributes the software, with or without <br>

 changes, must pass along the freedom to further copy and change it. <br>

Back <br>

References <br>

A Web site containing a wealth of information on Linux in general: <br>

www.kernel.org/LDP <br>

Web sites devoted to Linux on MIPS: <br>

www.paralogos.com/mipslinux <br>

www.linux-vr.org <br>

www.linux.sgi.com <br>

Web sites dealing with real-time Linux: <br>



www.rtlinux.org <br>

www.rtai.org <br>

Beck, M. et al. Linux Kernel Internals. New York: Addison-Wesley, 1998. This <br>

 book is a good source of information on the kernel internals. Rubini, Alesa <br>

ndro. Linux Device Drivers. Sebastopol, CA: O Reilly & Associates, 1998. Thi <br>

s book delves into kernel internals and talks in detail about all types of d <br>

evice drivers under Linux. <br>

  <br>

【 在 dross (走人了) 的大作中提到: 】 <br>

: 如果目标板不是使用i386结构的话呢 <br>

  <br>

  <br>

-- <br>

  人有时候需要一点点刺激 <br>

  人有时候需要一点点打击 <br>

  在那时侯不知道生命的意义就在超越自己 <br>

  争取一种意义非凡的胜利 <br>

  我们都是和自己赛跑的人 <br>

  为了更好的明天拼命努力 <br>

  <br>

  <br>

※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.184.38] <br>

</small><hr>
<p align="center">[<a href="嵌入式系统.htm">回到开始</a>][<a href="196.htm">上一层</a>][<a href="200.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -