Nuclear FAQ

zhaozj2021-02-11  216

Kernel FAQ (2001.05.01 ~ 2001.05.06) http://linuxaid.com.cn

Axing

Back to〗 Forward〗

1. I chose the sound card support when I compile the kernel. I also added the OSS to the module. Why is the following problem! 2, Bootsect.s, a small problem: Movsw problem 3, 0x20, & timer_interrupt where it did SCHEDULE4, Linux interrupted every 10ms, where did it do Schedule () 5, compiling the core Postal question: xwindow- -> Console can't see! 6, kernel_thread7, how to get the command code under Linux 1, I chose the sound card support when I compile the kernel, but also add the OSS to the module, why is the following problem! I chose the sound card support when I compile the core, but also joined the OSS to the module, why is the following problem! Information is: You DONT SEEM to HAVE A KERNEL with SOT MODULEENABED, isn't your compile core? Is it Yoss to choose Yoss? Yoss is MH734, but it is. Aztech's sound card, I haven't used it with OSS before, I don't know if you have this bad sound card! This will not be seen throughout the core: #make mrproper # make Clean # make menuConfig in the module's options to Yes, ie <*> or [*] method sound card in this section: Sound Card Support Selection [*] Other Both [M] Save After exiting, # make dep # make bzimage # make modules # make modules_install In order to find the module you compile, (Take 2.4.2 as an example), the generated module from /Lib/Modules/2.4 .2 / MISC / CP to / lib / modules / misc / then probe your SoundCoard, may be successful. 2, Bootsect.s Some of the problem: MOVSW problem IBM assembly, the operation of Movsw is: ((DI)) <- ((si)), then in the AT & T assembly ? What does the MOVSW instruction do? The CPU is always the same, but the format of the assembly method is different.

Some Example: MOVW% BX,% AX // MOV AX, BXXORL% EAX,% Eax // xor Eax, EaxmovW $ 1,% AX // MOV AX, 1MOVB X,% AH // Mov AH, byte PTR XMOVW X, % AX // MOV AX, Word PTR XMOVL X,% EAX / / MOV Eax, XB (8-bit), W (16-bit), L (32-bit) MOSTOPCODES Are Identical Between AF & T And Intel Format, Except Forthese: Movssd // Movsxmovzsd // Movzs, D Are The Source and Destinaion Operand Size Suffixes.Movswl% AX,% ECX // Movsx ECX, AXMAYBE Mean Something To you !! 3,0x20, & timer_interrupt 0x20, & Timer_Interrupt Where does it do SCHEDULE 100 interrupts / seconds (ie 10ms) may schedule () each interruption (), many other situations can also cause schedule (), such as programs, will actively request re-schedule when the program is lacking, Let the CPU. The rough process of 0x20 Timer_Interrupt is as follows: Come Clock Interrupt -> Save Scene -> Tag Information -> Do_BOTTOMHALF ---> Do you want to re-schedule? YES -> Scheduling NO -> Return 4 from the interruption, Linux is interrupted every 10ms, where is the schedule () Linux interrupt every 10ms, where did it do Schedule (). Whenever a system call or interrupt is completed, RET_FROM_SYS_CALL () will be called: CMPL $ 0, __ need_reschedjne reschedule is scheduled, and the clock interrupt is not 10MS once returned to schedule selection according to the specific situation. 5, the problem after compiling the core: xWindow -> console visible! I compiled 2.4.2, everything is normal, but after the new kernel is started, I can enter console and xwindow, but after entering xwindow, I use Ctrl Alt Backspace to want to go back to console, but Black screen, no matter what operation is done. However, you can restart using Ctrl Alt Del, and the STOP process can also be seen, but this command can work.

I use RedHat7.0, please help you! Thank you! It is very likely that the display mode switching and settings have been issued, suggest you: #CP / etc / x11 / xf86config / etc / x11 / xf86config_save_00 # xf86config reconfigure one over the x system, seeing not 6, kernel_thread kernel_thread (int .....) {... cmp %% sp, %% Si JE 1F Here is always going to 1:? ? ? ? ? ? ? .... 1: kernel_thread calls the Clone system call Create a new process (according to the flag decision is used with the same process number or another process number), Clone actually completed almost the same work, according to the return value of zero and non- Zero Decision is currently a new creation process and a parent process. The parent process jumps to 1. The new process calls the FN function. The control for Fork should be understood, and the other three ":" will cover some MOV grammar for the contract under Linux, you most Familiar with it.

7, how to get the command code under Linux How to get the code of various commands under Linux, such as ping, there is not provided in the AddUser system, you only find the source code from the Internet: * Ping.c / * / * ping source code distribute by CPU || Digger./* for unix family only. Compil and link surcess in sco unix./* i think. U can try it it./* Before Read this code, you shoud know about the principle of / * tcp / ip, especially icmp protocol, u also should also know some / * about BSD socket API, and unix system signal programming./*/* cc -o ping ping.c -LSocket, THEN U WILL GET EXECUTABLE FILE, / * But Must Act As Root When CC IT, And The Set Euid Attribute / * for this Ping, THEN U CAN EXECUTE IT AS Common User./* Because Only Root Can Have Authority To creat raw socket./*/* i love socket, if so do u, / * call me, cpu == digger # include # include # include # include # include # include # include # include # include # include # define ICMP_ECHO 8 / * Icmp echo request * / # define icmp_echoreply 0 / * icmp echo reply * / # define icmp_headsize 8 / * icmp packet header size * / # define IP_HEADSIZE 20 / * ip packet header size * / typedef struct tagIpHead / * icmp packet header * / {u_char ip_verlen; / * ip version and ip header lenth * / u_char ip_tos; / * ip type of service * / u_short ip_len; / * ip packet lenghth * / u_short ip_id; / * ip packet identification * / u_short ip_fragoff; / * ip packet fragment and offset * / u_char ip_ttl; / * ip packet time to live * / u_char ip_proto; / * ip packet protocol type * / u_short ip_chksum; / * ip packet header checksum * / u_long ip_src_addr; / * ip source ip adress * / u_long ip_dst_addr; / * ip destination ip adress * /} IPHEAD; typedef struct tagIcmpHead / * icmp header * / {u_char icmp_type; / * ICMP Service Type * /// * 8 Echo Require, 0 echo reply * / u_char ICMP_CODE

/ * Icmp header code * / u_short icmp_chksum; / * icmp header chksum * / u_short icmp_id; / * icmp packet identification * / u_short icmp_seq; / * icmp packet sequent * / u_char icmp_data [1]; / * icmp data, use as pointer * /} ICMPHEAD; u_short ChkSum (u_short * pIcmpData, int iDataLen) / * for check sum of icmp header * / {u_short iSum; u_short iOddByte; iSum = 0; while (iDataLen> 1) {/ * xor the next unsigned INT DATA * / ISUM ^ = * picmpdata ; iDatalen - = 2;} if (idata == 1) {/ * the rest == = 0; * ((u_char *) & oddbyte) = * (u_char *) Picmpdata; isum ^ = oddbyte;}}} ^ ^ = 0xfff; / * xor 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffff; it * / return () / * Return Time Passed by * /// * Since 1970.1.1 00:00 : 00, * // * in 1/1000000 second * / {struct timeVal now; long lparassed; gettimeofday (& now, 0); lparassed = now.tv_sec * 1000000 now.tv_usec; ​​/ * now.tv_sec in second * / / * Now.tv_usec in 1/1000000 Second * / Return LPASSED;} char * host; / * destination host * / char * prog; / * program name * / extern errno; / * System Global PARA; / * SYSTEM GLOBAL PARA Meter * / long lsendtime; / * each time when send, change it * / u_short seq; / * the icmp packet seqence * / int itimeout; / * Time Out parameter * / int Sock, Sent, Recvd, Max, Min, Total ; / * SENT: ICMP Packet Already Sent * // * Recvd: Proper ICMP Packet Received * /// * max, min: Max Min Round Trip Time * /// * Total: Total Round Trip Time * /// * Store to Calculate Average * / u_long lhostip; / * host ip adress * / structure sockaddr_in it; / * destination host information * / int ping (); void stat (); main (int argc, char ** argv) {struct hostent * h; char BUF [200]; char dst_host [32]; int I, namelen; iphead * piphead; icmphead * picmphead; if (Argc <

2) {/ * ping the desinter * // * every timeout second * // * default timeout is 1 second * / printf ("usage:% s [-timeout] host | ip", argv [0]); exit (0); prog = argv [0]; host = argc == 2? Argv [1]: argv [2]; itimeout = argc == 2? 1: ATOI (Argv [1]); / * Creat THE Raw Socket for ICMP * / IF ((Sock = Socket, Sock_RAW, IPPROTO_ICMP)) <0) {Perror ("Socket"); EXIT (2);} / * set destination host information * / bzero (& it, sizeof (IT)); it.sin_family = AF_INET; / * CHECK HOST FORMAT * / IF (Lhostip = INET_ADDR (Host))! = INADDR_NONE) {/ * is available ip adress * / it.sin_addr.s_addr = lhostip; STRCPY (DST_HOST, HOST);} else if (h = gethostbyname (host)) {/ * is available host name * // * from hosts file of local host * // * or from dns * / bcopy (h-> h_addr, & it.sin_addr, h-> h_length); Sprintf (DST_HOST, "% s (% s)", Host, INET_NTOA (IT.SIN_ADDR));} else {/ * bad ip adress or host name * // * EXIT * / fprintf (stderr, "bad ip or host"); exit (3);} namelen = sizeof (it); printf ("Digger Pinging% S, Send% D Bytes", DST_ Host, IP_HEADSIZE ICMP_HEADSIZE SIZEOF (long); SEQ = 0; / * first ICMP_SEQ = 0 * / SigSet (SIGINT, STAT); / * WHEN PRESS DEL OR CTRL C, Call Stat * // * To Statistic THE Result, and life,; / * hook ping function to time * / alarm (itimeout); / * Start Timer, Call ping every timeout * // * seconds * / ping (); for ;;) {/ * waiting for every echo back * // * icmp packet and check it * / register size; register u_char ttl; register delta; register iIpHeadLen; / * block to received echo back datagram * / size = recvfrom (sock , BUF, SIZEOF (BUF), 0, (Struct SockAddr *) & It, & Namelen; IF (size =

= -1 && errno == Eintr) {/ * receive error or system call * // * interrupted * / continue;} / * calculate the round trip time, * // * Time when received minus time when desund * / delta = (int) ((time_now () - lsendtime) / 1000); / * get echo back packet and check its ip header * / piphead = (ipHead *) buf; / * get the ip packet layer * // * if too small ip , Not the icmp echoreply packet * // * Give it up * / iipheadlen = (int) ((piphead-> ip_verlen & 0x0f) << 2); if (size ip_ttl; / * time to live param * // * get the icmp header information * / picmphead = (icmphead *) (BUF IPHEADLEN); / * NOT ICMP ECHO Reply Packet, Give IT Up * / if (PicmpHead-> ! icmp_type = ICMP_ECHOREPLY) {continue;} / * not proper icmp sequent number, give it up * / if (pIcmpHead-> icmp_id = seq || pIcmpHead-> icmp_seq = seq) {continue;}!! / * print out result For Each ICMP * /// * echo reply information * / sprintf (buf, "ICMP_SEQ =% u Bytes =% D TTL =% D", PICMPHEAD-> ICMP_SEQ, SIZE, TTL); FPRINTF (stderr, "reply from% s :% S Time =% D MS ", Host, BUF, Delta); / * Calculate Some Statistic Information * // * Max, Min, Average Round Trip Time * // * Received ICMP Echo Reply Packet NumBers * / Max = Max (delta, max); min = min? min (delta, min): delta; total = delta; Recvd; / * for next icmp sequence * / seq;}} ping () {Char BUF [200 ]; int iPacketSize; / * make the icmp header information * / ICMPHEAD * pIcmpHead = (ICMPHEAD *) buf; pIcmpHead-> icmp_type = ICMP_ECHO; pIcmpHead-> icmp_code = 0; pIcmpHead-> icmp_id = seq; pIcmpHead-> icmp_seq = SEQ; picmphead-> ICMP_CHKSUM = 0;

转载请注明原文地址:https://www.9cbs.com/read-3522.html

New Post(0)