24.01.2014 Views

Codice

Codice

Codice

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

292 volume VI os16<br />

Script e sorgenti del kernel 293<br />

1960030 |void tty_init (void);<br />

1960031 |<br />

1960032 |#endif<br />

1990029 |}<br />

104.10.4 kernel/tty/tty_reference.c<br />

«<br />

104.10.1 kernel/tty/tty_console.c<br />

Si veda la sezione 103.9.<br />

1970001 |#include <br />

1970002 |#include <br />

1970003 |//----------------------------------------------------------------------<br />

1970004 |dev_t<br />

1970005 |tty_console (dev_t device)<br />

1970006 |{<br />

1970007 | static dev_t device_active = DEV_CONSOLE0; // First time.<br />

1970008 | dev_t device_previous;<br />

1970009 | //<br />

1970010 | // Check if it required only the current device.<br />

1970011 | //<br />

1970012 | if (device == 0)<br />

1970013 | {<br />

1970014 | return (device_active);<br />

1970015 | }<br />

1970016 | //<br />

1970017 | // Fix if the device is not valid.<br />

1970018 | //<br />

1970019 | if (device > DEV_CONSOLE3 || device < DEV_CONSOLE0)<br />

1970020 | {<br />

1970021 | device = DEV_CONSOLE0;<br />

1970022 | }<br />

1970023 | //<br />

1970024 | // Update.<br />

1970025 | //<br />

1970026 | device_previous = device_active;<br />

1970027 | device_active = device;<br />

1970028 | //<br />

1970029 | // Switch.<br />

1970030 | //<br />

1970031 | con_select (device_active & 0x00FF);<br />

1970032 | //<br />

1970033 | // Return previous device value.<br />

1970034 | //<br />

1970035 | return (device_previous);<br />

1970036 |}<br />

104.10.2 kernel/tty/tty_init.c<br />

Si veda la sezione 103.9.<br />

2000001 |#include <br />

2000002 |//----------------------------------------------------------------------<br />

2000003 |tty_t *<br />

2000004 |tty_reference (dev_t device)<br />

2000005 |{<br />

2000006 | int t; // Terminal index.<br />

2000007 | //<br />

2000008 | // If device is zero, a reference to the whole table is returned.<br />

2000009 | //<br />

2000010 | if (device == 0)<br />

2000011 | {<br />

2000012 | return (tty_table);<br />

2000013 | }<br />

2000014 | //<br />

2000015 | // Otherwise, a scan is made to find the selected device.<br />

2000016 | //<br />

2000017 | for (t = 0; t < TTYS_TOTAL; t++)<br />

2000018 | {<br />

2000019 | if (tty_table[t].device == device)<br />

2000020 | {<br />

2000021 | //<br />

2000022 | // Device found. Return the pointer.<br />

2000023 | //<br />

2000024 | return (&tty_table[t]);<br />

2000025 | }<br />

2000026 | }<br />

2000027 | //<br />

2000028 | // No device found!<br />

2000029 | //<br />

2000030 | return (NULL);<br />

2000031 |}<br />

104.10.5 kernel/tty/tty_table.c<br />

Si veda la sezione 103.9.<br />

2010001 |#include <br />

2010002 |//----------------------------------------------------------------------<br />

2010003 |tty_t tty_table[TTYS_TOTAL];<br />

«<br />

«<br />

«<br />

Si veda la sezione 103.9.<br />

104.10.6 kernel/tty/tty_write.c<br />

1980001 |#include <br />

1980002 |#include <br />

1980003 |//----------------------------------------------------------------------<br />

1980004 |void<br />

1980005 |tty_init (void)<br />

1980006 |{<br />

1980007 | int page; // console page.<br />

1980008 | //<br />

1980009 | // Console initialization: console pages correspond to the first<br />

1980010 | // terminal items.<br />

1980011 | //<br />

1980012 | for (page = 0; page < TTYS_CONSOLE; page++)<br />

1980013 | {<br />

1980014 | tty_table[page].device = DEV_CONSOLE0 + page;<br />

1980015 | tty_table[page].pgrp = 0;<br />

1980016 | tty_table[page].key = 0;<br />

1980017 | tty_table[page].status = TTY_OK;<br />

1980018 | }<br />

1980019 | //<br />

1980020 | // Set video mode.<br />

1980021 | //<br />

1980022 | con_init ();<br />

1980023 | //<br />

1980024 | // Select the first console.<br />

1980025 | //<br />

1980026 | tty_console (DEV_CONSOLE0);<br />

1980027 | //<br />

1980028 | // Nothing else to configure (only consoles are available).<br />

1980029 | //<br />

1980030 | return;<br />

1980031 |}<br />

Si veda la sezione 103.9.<br />

2020001 |#include <br />

2020002 |#include <br />

2020003 |//----------------------------------------------------------------------<br />

2020004 |void<br />

2020005 |tty_write (dev_t device, int c)<br />

2020006 |{<br />

2020007 | int console;<br />

2020008 | //<br />

2020009 | if ((device & 0xFF00) == (DEV_CONSOLE_MAJOR key;<br />

1990023 | tty->key = 0;<br />

1990024 | //<br />

1990025 | // Return the key.<br />

1990026 | //<br />

1990027 | return (key);<br />

1990028 |

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!