From 7671e92216a286f9b7a10c5bca4e37a58a75f48a Mon Sep 17 00:00:00 2001
From: Skallwar <estblcsk@gmail.com>
Date: Fri, 6 Mar 2020 21:01:18 +0100
Subject: [PATCH] Fix borrow of packed field

---
 src/devices/uart_16550.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/devices/uart_16550.rs b/src/devices/uart_16550.rs
index d482504b..b1b8e8d4 100644
--- a/src/devices/uart_16550.rs
+++ b/src/devices/uart_16550.rs
@@ -67,6 +67,7 @@ impl<T: Io> SerialPort<T>
 {
     pub fn init(&mut self) {
         //TODO: Cleanup
+        unsafe {
         self.int_en.write(0x00.into());
         self.line_ctrl.write(0x80.into());
         self.data.write(0x01.into());
@@ -75,18 +76,19 @@ impl<T: Io> SerialPort<T>
         self.fifo_ctrl.write(0xC7.into());
         self.modem_ctrl.write(0x0B.into());
         self.int_en.write(0x01.into());
+        }
     }
 
     fn line_sts(&self) -> LineStsFlags {
         LineStsFlags::from_bits_truncate(
-            (self.line_sts.read() & 0xFF.into()).try_into().unwrap_or(0)
+            (unsafe {self.line_sts.read()} & 0xFF.into()).try_into().unwrap_or(0)
         )
     }
 
     pub fn receive(&mut self) -> Option<u8> {
         if self.line_sts().contains(LineStsFlags::INPUT_FULL) {
             Some(
-                (self.data.read() & 0xFF.into()).try_into().unwrap_or(0)
+                (unsafe {self.data.read()} & 0xFF.into()).try_into().unwrap_or(0)
             )
         } else {
             None
@@ -95,7 +97,7 @@ impl<T: Io> SerialPort<T>
 
     pub fn send(&mut self, data: u8) {
         while ! self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY) {}
-        self.data.write(data.into());
+        unsafe {self.data.write(data.into())}
     }
 
     pub fn write(&mut self, buf: &[u8]) {
-- 
GitLab