@@ -47,24 +47,32 @@ static void e1000e_write_flush(void) {
4747 (void )flush ;
4848}
4949
50- static bool e1000e_wait (uint32_t reg , uint32_t mask , bool expect_nonzero , time_t timeout_seconds ) {
51- time_t start = time (NULL );
50+ static bool e1000e_wait (uint32_t reg , uint32_t mask , bool expect_nonzero , uint32_t timeout_us )
51+ {
52+ uint32_t waited = 0 ;
53+
54+ while (1 ) {
55+ bool set = (e1000e_read_command (reg ) & mask ) != 0 ;
56+
57+ if (set == expect_nonzero ) {
58+ return true;
59+ }
5260
53- while (((e1000e_read_command (reg ) & mask ) != 0 ) != expect_nonzero ) {
54- if (time (NULL ) - start > timeout_seconds ) {
61+ if (waited >= timeout_us ) {
5562 return false;
5663 }
57- }
5864
59- return true;
65+ delay_us (1 );
66+ waited ++ ;
67+ }
6068}
6169
62- static bool e1000e_wait_clear (uint32_t reg , uint32_t mask , time_t timeout_seconds ) {
63- return e1000e_wait (reg , mask , false, timeout_seconds );
70+ static bool e1000e_wait_clear (uint32_t reg , uint32_t mask , uint32_t timeout_us ) {
71+ return e1000e_wait (reg , mask , false, timeout_us );
6472}
6573
66- static bool e1000e_wait_set (uint32_t reg , uint32_t mask , time_t timeout_seconds ) {
67- return e1000e_wait (reg , mask , true, timeout_seconds );
74+ static bool e1000e_wait_set (uint32_t reg , uint32_t mask , uint32_t timeout_us ) {
75+ return e1000e_wait (reg , mask , true, timeout_us );
6876}
6977
7078static bool e1000e_detect_eeprom (void ) {
@@ -168,7 +176,7 @@ static bool e1000e_reset_hw(void) {
168176 io_wait ();
169177 }
170178
171- if (!e1000e_wait_clear (REG_CTRL , E1000_CTRL_RST , 1 )) {
179+ if (!e1000e_wait_clear (REG_CTRL , E1000_CTRL_RST , 100000 )) {
172180 dprintf ("e1000e: reset timed out\n" );
173181 return false;
174182 }
@@ -515,6 +523,7 @@ void init_e1000e(void) {
515523 E1000E_82574L ,
516524 E1000E_82574LA ,
517525 E1000E_82583V ,
526+ E1000E_I217LM ,
518527 };
519528
520529 for (size_t i = 0 ; i < sizeof (supported ) / sizeof (supported [0 ]); i ++ ) {
0 commit comments