MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / init

Method init

src/dev/drivers/pic8259.rs:89–124  ·  view source on GitHub ↗

Initialize both PIC simultaneously.

(&mut self)

Source from the content-addressed store, hash-verified

87
88 // Initialize both PIC simultaneously.
89 pub unsafe fn init(&mut self)
90 {
91 // Wait between writes to the PIC.
92 let mut waitport: Port<u8>= Port::new(0x80);
93 let mut wait = || waitport.write(0);
94
95 // Save interrupt masks.
96 let mask_save = self.mask_read();
97
98 // Alert each PIC to an incoming initialization sequence.
99 self.pics[0].cmd.write(INIT_CMD);
100 wait();
101 self.pics[1].cmd.write(INIT_CMD);
102 wait();
103
104 // Byte 1/3 - Establish base offsets.
105 self.pics[0].data.write(self.pics[0].offset);
106 wait();
107 self.pics[1].data.write(self.pics[1].offset);
108 wait();
109
110 // Byte 2/3 - Coordinate the chain between the pair of PIC.
111 self.pics[0].data.write(4);
112 wait();
113 self.pics[1].data.write(2);
114 wait();
115
116 // Byte 3/3 - Set the PIC mode.
117 self.pics[0].data.write(MODE_8086);
118 wait();
119 self.pics[1].data.write(MODE_8086);
120 wait();
121
122 // Restore the previously saved masks.
123 self.mask_write(mask_save[0], mask_save[1])
124 }
125
126 // Read interrupt mask for both PIC, respectively.
127 pub unsafe fn mask_read(&mut self) -> [u8; 2]

Callers

nothing calls this directly

Calls 3

mask_readMethod · 0.80
mask_writeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected