@@ -57,7 +57,6 @@ mod timer;
5757pub use net:: { TcpStream , UdpHandle , PACKET_SIZE } ;
5858
5959struct UefiOSImpl {
60- timer : Timer ,
6160 rng : Rng ,
6261 tasks : Vec < Arc < Task > > ,
6362 input : ScopedProtocol < Input > ,
@@ -163,7 +162,7 @@ impl UefiOS {
163162 . unwrap ( ) ;
164163 }
165164
166- let timer = Timer :: new ( ) ;
165+ Timer :: ensure_init ( ) ;
167166 let rng = Rng :: new ( ) ;
168167
169168 let input_handles = uefi:: boot:: find_handles :: < Input > ( ) . unwrap ( ) ;
@@ -179,7 +178,6 @@ impl UefiOS {
179178 vga. clear ( ) . unwrap ( ) ;
180179
181180 * OS . borrow_mut ( ) = Some ( UefiOSImpl {
182- timer,
183181 rng,
184182 tasks : Vec :: new ( ) ,
185183 input,
@@ -227,9 +225,8 @@ impl UefiOS {
227225 os. spawn (
228226 "[net_poll]" ,
229227 poll_fn ( move |cx| {
230- let ( mut net, timer) =
231- RefMut :: map_split ( os. borrow_mut ( ) , |os| ( & mut os. net , & mut os. timer ) ) ;
232- net. as_mut ( ) . unwrap ( ) . poll ( & timer) ;
228+ let mut os = os. borrow_mut ( ) ;
229+ os. net . as_mut ( ) . unwrap ( ) . poll ( ) ;
233230 // TODO(veluca): figure out whether we can suspend the task.
234231 cx. waker ( ) . wake_by_ref ( ) ;
235232 Poll :: Pending
@@ -239,10 +236,10 @@ impl UefiOS {
239236 os. spawn ( "[net_speed]" , async move {
240237 let mut prx = 0 ;
241238 let mut ptx = 0 ;
242- let mut ptm = os . timer ( ) . instant ( ) ;
239+ let mut ptm = Timer :: instant ( ) ;
243240 loop {
244241 {
245- let now = os . timer ( ) . instant ( ) ;
242+ let now = Timer :: instant ( ) ;
246243 let dt = ( now - ptm) . total_micros ( ) as f64 / 1_000_000.0 ;
247244 ptm = now;
248245
@@ -263,7 +260,7 @@ impl UefiOS {
263260 }
264261 } ) ;
265262
266- Executor :: run ( os )
263+ Executor :: run ( )
267264 }
268265
269266 fn borrow ( & self ) -> Ref < ' static , UefiOSImpl > {
@@ -274,10 +271,6 @@ impl UefiOS {
274271 RefMut :: map ( OS . borrow_mut ( ) , |f| f. as_mut ( ) . unwrap ( ) )
275272 }
276273
277- pub fn timer ( & self ) -> Ref < ' static , Timer > {
278- Ref :: map ( self . borrow ( ) , |f| & f. timer )
279- }
280-
281274 pub fn rng ( & self ) -> RefMut < ' static , Rng > {
282275 RefMut :: map ( self . borrow_mut ( ) , |f| & mut f. rng )
283276 }
@@ -317,9 +310,9 @@ impl UefiOS {
317310 }
318311
319312 pub fn sleep_us ( self , us : u64 ) -> impl Future < Output = ( ) > {
320- let tgt = self . timer ( ) . micros ( ) as u64 + us;
313+ let tgt = Timer :: micros ( ) as u64 + us;
321314 poll_fn ( move |cx| {
322- let now = self . timer ( ) . micros ( ) as u64 ;
315+ let now = Timer :: micros ( ) as u64 ;
323316 if now >= tgt {
324317 Poll :: Ready ( ( ) )
325318 } else {
@@ -431,7 +424,7 @@ impl UefiOS {
431424 fn draw_ui ( & self ) {
432425 // Write the header.
433426 {
434- let time = self . timer ( ) . micros ( ) as f32 * 0.000_001 ;
427+ let time = Timer :: micros ( ) as f32 * 0.000_001 ;
435428 let ip = self . net ( ) . ip ( ) ;
436429 let mut os = self . borrow_mut ( ) ;
437430
@@ -572,7 +565,7 @@ impl log::Log for UefiOS {
572565 }
573566
574567 fn log ( & self , record : & log:: Record ) {
575- let now = self . timer ( ) . micros ( ) as f64 * 0.000_001 ;
568+ let now = Timer :: micros ( ) as f64 * 0.000_001 ;
576569 self . append_message (
577570 now,
578571 record. level ( ) ,
0 commit comments