Rev 154 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 154 | Rev 166 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | \section{Kernel Start} |
3 | \section{Kernel Start} |
4 | When the HelenOS kernel starts up, it configures its output device |
4 | When the HelenOS kernel starts up, it configures its output device |
5 | and starts booting. During the boot process it writes out some some |
5 | and starts booting. During the boot process it writes out some some |
6 | lines regarding memory size and available CPUs. The userspace |
6 | lines regarding memory size and available CPUs. The userspace |
7 | drivers and tasks take over the console as soon as the start-up activity |
7 | drivers and tasks take over the console as soon as the start-up activities are finished. |
8 | and developer kernel tests are finished. |
8 | When kernel tests are compiled in, the userspace layer is not started. |
9 | 9 | ||
10 | The console driver provides 12 virtual consoles, 11 reserved |
10 | The console driver provides 12 virtual consoles, 11 are used |
11 | for applications, console 12 is reserved for kernel console. Pressing |
11 | for applications, console 12 is reserved for kernel console. Pressing |
12 | function keys F1-F12 switches between the consoles. |
12 | function keys F1-F12 switches between the consoles. |
13 | 13 | ||
14 | If the architecture supports framebuffer device larger with |
14 | If the architecture supports framebuffer device with |
15 | resolution at least 800x600, nice graphical console is shown. At the top |
15 | at least 800x600 resolution, a nice graphical console is shown. At the top |
16 | of the screen a row of buttons for the virtual console is drawn. If |
16 | of the screen, a row of buttons for the virtual console is drawn. If |
17 | the button contains console number, an application is connected to it. |
17 | the button contains console number, an application is connected to it. |
18 | The red button signifies that there was an activity on the terminal |
18 | The red button means that there was an activity on the terminal |
19 | since it was last shown to the user. |
19 | since it was last shown to the user. |
20 | 20 | ||
21 | \section{KConsole} |
21 | \section{Kernel Console} |
22 | KConsole is a kernel thread operating completely in priviledged mode. |
22 | {\em kconsole} is a kernel thread operating completely in priviledged mode. |
23 | It allows user to interact directly with the kernel and even start directly |
23 | It allows the user to interact directly with the kernel and even start directly |
24 | functions inside the kernel. |
24 | functions inside the kernel. |
25 | 25 | ||
26 | The KConsole is shown by switching to console number 12. On some platforms |
26 | The kernel console is shown by switching to console number 12. On some platforms |
27 | the kconsole screen is not restored to its previous contents. Press |
27 | the kconsole screen is not restored to its previous contents. Press |
28 | enter to see a KConsole prompt. The function keys for switching terminals |
28 | enter to see {\em kconsole}'s prompt. The function keys for switching terminals |
29 | do not work in KConsole, to switch back to other console, use |
29 | do not work in the console. In order to switch back to other consoles, use |
30 | the {\em continue} command. After executing the command, press a function key |
30 | the {\em continue} command. After executing the command, press a function key |
31 | to switch to other consoles. |
31 | to switch to the console of your choice. |
32 | 32 | ||
33 | The basic editing facilities are very similar to {\em readline} conventions. |
33 | The basic editing facilities are very similar to {\em readline} conventions. |
34 | The left and right arrows, backspace and delete keys allow for convenient |
34 | The left and right arrows, backspace and delete keys allow convenient |
35 | editing of the text. The history of last ten commands can be retrieved |
35 | editing of text. The history of last ten commands can be retrieved |
36 | using up and down arrows. KConsole supports tab completion, double tab |
36 | using up and down arrows. The kernel console supports tab completion, double tab |
37 | shows a list of available commands. |
37 | shows a list of available commands. |
38 | 38 | ||
39 | The first class of commands prints useful statistics from the running |
39 | The first class of commands prints useful statistics from the running |
40 | operating systems. The commands are: |
40 | operating systems. The commands are: |
41 | \begin{description} |
41 | \begin{description} |
42 | \item[zones] --- Prints a list of memory zones. |
42 | \item[zones] --- Prints a list of memory zones. |
43 | \item[zone $<$zone number$>$] --- Prints a detailed statistics about frame allocator. |
43 | \item[zone $<$zone number$>$] --- Prints a detailed statistics about the frame allocator. |
44 | \item[slabs] --- Prints a details statistics about slab allocator. |
44 | \item[slabs] --- Prints detailed statistics about the slab allocator. |
45 | \item[scheduler] --- Prints scheduler queues on all cpus. |
45 | \item[scheduler] --- Prints out the contents of scheduler run queues for all cpus. |
46 | \item[threads] --- Prints list of existing threads, including information about |
46 | \item[threads] --- Prints list of existing threads, including information about |
47 | the thread state |
47 | their state. |
48 | \item[tasks] --- Prints list of tasks along with some basic IPC informations. |
48 | \item[tasks] --- Prints list of tasks along with some basic IPC information. |
49 | \item[ipc\_task $<$taskid$>$] --- Prints detailed information about IPC queues of a particular task. |
49 | \item[ipc\_task $<$taskid$>$] --- Prints detailed information about IPC queues of a particular task. |
50 | \item[tlb] --- Prints contents of the Translation Lookaside Buffer on a processor (supported only on some platforms) |
50 | \item[tlb] --- Prints contents of the Translation Lookaside Buffer on a processor (supported only on some platforms). |
51 | \item[exc] --- Prints table of registered exception handlers |
51 | \item[exc] --- Prints table of registered exception handlers. |
52 | \end{description} |
52 | \end{description} |
53 | 53 | ||
54 | Kernel contains a searchable version of its symbol table. This is used |
54 | The kernel contains a searchable version of its symbol table. This is used |
55 | in error processing as well as for extending functionality of KConsole. |
55 | in error processing as well as for extending functionality of the kernel console. |
56 | The following commands are supported: |
56 | The following commands are supported: |
57 | \begin{description} |
57 | \begin{description} |
58 | \item[symaddr $<$address$>$] --- Finds an address in symbol table and prints appropriate |
58 | \item[symaddr $<$address$>$] --- Finds an address in symbol table and prints the appropriate |
59 | symbol name. |
59 | symbol name. |
60 | \item[call0, call1... $<$function$>$ $<$args...$>$] --- Calls a C function function(args...). |
60 | \item[call0, call1... $<$function$>$ $<$args...$>$] --- Calls a C function {\em function(args...)}. |
61 | Note that the tab-completion works for the function names. Because |
61 | Note that the tab-completion also works for function names. Because |
62 | of architecture calling convention, this command does not work correctly |
62 | of architecture calling convention, this command does not work correctly |
63 | on the ia64 platform. The arguments can be specified |
63 | on the ia64 platform. The arguments can be specified |
64 | \begin{itemize} |
64 | \begin{itemize} |
65 | \item as a number or hexadecimal number: call1 task\_kill 8 |
65 | \item as a number or hexadecimal number: call1 task\_kill 8 |
66 | \item as a string: call1 printf "Hello world" |
66 | \item as a string: call1 printf "Hello world" |
67 | \item as a hexadecimal number preceded by '*'. The argument is then read from |
67 | \item as a hexadecimal number preceeded by '*'. The argument is then read from |
68 | the given address: call2 printf "%X" *0x8000000 |
68 | the given address: call2 printf "%X" *0x8000000 |
69 | \item as a symbol name. In such case the value located in the memory |
69 | \item as a symbol name. In such case, the value located in the memory |
70 | in the symbols address is used: call2 printf "%d" task_counter |
70 | location corresponding to the symbol name is used: call2 printf "%d" task_counter |
71 | \item as a symbol name preceded by '\&'. The address is used. |
71 | \item as a symbol name preceeded by '\&'. The address is used. |
72 | \item as a symbol name preceded by '*'. In such a case the symbol is dereferenced. |
72 | \item as a symbol name preceeded by '*'. In such case, the symbol is dereferenced. |
73 | \end{itemize} |
73 | \end{itemize} |
74 | \item[set4 <address|symbol name>] --- Saves 4-byte value on a given address. |
74 | \item[set4 <address|symbol name>] --- Stores a 4-byte value into a given address. |
75 | \end{description} |
75 | \end{description} |
76 | 76 | ||
77 | The mips, ia32 and amd64 platforms provide additional commands regarding |
77 | The mips32, ia32 and amd64 platforms provide additional commands regarding |
78 | debugging facility - set and clear hardware breakpoints and watchpoints. |
78 | debugging facility - set and clear hardware breakpoints and watchpoints. |
79 | 79 | ||
80 | \section{KConsole Task Control} |
80 | \section{Kernel Console Task Control} |
81 | KConsole {\em call} commands can be used to start and kill the tasks. |
81 | The kconsole {\em call} commands can be used to start and kill tasks. |
82 | To repeatably start the task, the following procedure should be used: |
82 | To repeatably start a task, the following procedure should be used: |
83 | \begin{verbatim} |
83 | \begin{verbatim} |
84 | .... kernel boot data .... |
84 | .... kernel boot data .... |
85 | init[8].addr=0x8027b000, init[8].size=86016 |
85 | init[8].addr=0x8027b000, init[8].size=86016 |
86 | .... rest of boot data ... |
86 | .... rest of boot data ... |
87 | kconsole> call2 task_run_program 0x8027b000 0 |
87 | kconsole> call2 task_run_program 0x8027b000 0 |
88 | Calling f(0x8027b000,0): 0x80119283: generic/src/proc/task.o:task_run_program |
88 | Calling f(0x8027b000,0): 0x80119283: generic/src/proc/task.o:task_run_program |
89 | Result: 0x80086500 |
89 | Result: 0x80086500 |
90 | \end{verbatim} |
90 | \end{verbatim} |
91 | 91 | ||
92 | To kill a task, the function {\em task\_kill} is appropriate. The {\em taskid} |
92 | To kill a task, use of the function {\em task\_kill} is appropriate. The {\em taskid} |
93 | parameter is a 64-bit number on all platforms, thus on the 32-bit platforms |
93 | parameter is a 64-bit number on all platforms, thus on the 32-bit platforms |
94 | call2 should be used with 2 32-bit parameters instead. |
94 | call2 should be used with 2 32-bit parameters instead. |
95 | \begin{verbatim} |
95 | \begin{verbatim} |
96 | kconsole> call2 task_kill 8 0 |
96 | kconsole> call2 task_kill 8 0 |
97 | Calling f(0x8,0x0): 0x801197e8: generic/src/proc/task.o:task_kill |
97 | Calling f(0x8,0x0): 0x801197e8: generic/src/proc/task.o:task_kill |
98 | Result: 0x0 |
98 | Result: 0x0 |
99 | \end{verbatim} |
99 | \end{verbatim} |
100 | 100 | ||
101 | \section{Emergency Functions} |
101 | \section{Emergency Functions} |
102 | It may happen that the IPC communication dies or that there appear some |
102 | It may happen that the IPC communication dies or that some |
103 | problems in the communication chain |
103 | problems arise in the communication chain |
104 | {\em keboard driver} - {\em console} - {\em output driver}. |
104 | {\em keboard driver} - {\em console} - {\em output driver}. |
105 | As long that at least the keyboard driver works, pressing Escape key three |
105 | As long as at least the keyboard driver works, pressing Escape key three |
106 | times transfers control to the KConsole immediately. Because the screen is not |
106 | times transfers control to the kernel console immediately. Because the screen is not |
107 | updated, the user should press Enter to see the kconsole prompt. |
107 | updated, the user should press Enter to see the kconsole prompt. |
108 | 108 | ||
109 | If a kernel panic occurs, the error handling automatially switches control |
109 | If a kernel panic occurs, the error handling automatially switches control |
110 | to the KConsole and allows users to inspect the failed kernel online. |
110 | to the KConsole and allows users to inspect the failed kernel online. |
111 | On the SMP system the other processors are halted immediately. The kernel |
111 | On the SMP system the other processors are halted immediately. The kernel |
112 | contains its symbol table, so you can probably read some useful information |
112 | contains its symbol table, so you can probably read some useful information |
113 | about the exact place where the panic occured. |
113 | about the exact place where the panic occured. |
114 | 114 | ||
115 | \section{How to Do a Kernel Panic} |
115 | \section{How to Do a Kernel Panic} |
116 | Kernel panic is extremely rare in HelenOS. However, if the user wishes to |
116 | Kernel panic is extremely rare in HelenOS. However, if the user wishes to |
117 | simulate it, KConsole contains proper commands. For example the following |
117 | simulate it, the kernel console contains proper commands. For example, the following |
118 | command simulates a write to the unmapped address 0x4: |
118 | command simulates a write to the unmapped address 0x4: |
119 | \begin{verbatim} |
119 | \begin{verbatim} |
120 | kconsole> set4 4 0 |
120 | kconsole> set4 4 0 |
121 | \end{verbatim} |
121 | \end{verbatim} |
122 | 122 | ||
123 | To test the autodebugging possibilities of the IA32 platform, the following |
123 | To test the autodebugging possibilities of the ia32 platform, the following |
124 | sequence can be executed: |
124 | sequence can be executed: |
125 | \begin{verbatim} |
125 | \begin{verbatim} |
126 | kconsole> bkpts |
126 | kconsole> bkpts |
127 | 0. 0x80032010 in (NULL) |
127 | 0. 0x80032010 in (NULL) |
128 | Count(0) |
128 | Count(0) |
Line 133... | Line 133... | ||
133 | debug> |
133 | debug> |
134 | \end{verbatim} |
134 | \end{verbatim} |
135 | 135 | ||
136 | 136 | ||
137 | \section{KLog} |
137 | \section{KLog} |
138 | To avoid disturbing the framebuffer driver with kernel messages, a circular |
138 | In order to avoid disturbing the framebuffer driver with kernel messages, a circular |
139 | buffer communication between kernel and userspace area is established. |
139 | buffer communication between the kernel and the userspace area is established. |
140 | Non-critical messages are sent to the |
- | |
141 | KLog application. User can see messages about task faults |
140 | Non-critical messages are sent to the KLog application. The user can see messages about |
142 | and task cleanup completion. |
141 | task faults and task cleanup completion. |
143 | 142 | ||
144 | \section{IPCC - testing application} |
143 | \section{IPCC - testing application} |
145 | To test thouroughly some aspects of the task activities, IPCC application |
144 | For the sake of thourough testing of some aspects of task activities, IPCC application |
- | 145 | allows the user to generate faulting behaviour such as page faults and unaligned references\footnote{Some architectures |
|
146 | allows user to generate page faults |
146 | do not fault on an unaligned memory reference.}. |
147 | 147 | ||
148 | \section{Tetris} |
- | |
149 | 148 |