81b9 Problems with uptime() and pause() at system boot time - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > FreeBSD Development

FreeBSD Development Kernel development, writing drivers, coding, and questions regarding FreeBSD internals.

Reply
 
Thread Tools Display Modes
  #1  
Old October 31st, 2011, 17:30
mburnicki mburnicki is offline
Junior Member
 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with uptime() and pause() at system boot time

Hi,

I'm currently working on a FreeBSD device driver for some PCI cards manufactured by our company (Meinberg).

One of the PCI cards needs a certain time interval to become ready to be accessed after power-up, i.e. the card's driver must not access such card before a required uptime has been reached (I know this is ugly, but there's no way to avoid this).

So my idea was to use a code sequence like this in the initialization function for this type of PCI card, before the card is actually accessed by the driver:

Code:
while (1)
{
  struct timeval tv = { 0 };
  struct bintime bt;

  binuptime(&bt);

  if ( bt.sec > required_uptime )
    break;

  // we must wait, so sleep 1 second, then try again
  tv.tv_sec = 1;
  pause( "pause", tvtohz( &tv ) );
}
When the system is already up and running and then my driver module is loaded manually by the kldload command then everything works fine, i.e. binuptime returns reasonable values and pause() delays execution for about 1 second, as expected.

However, if my kernel module is loaded automatically at boot time (I have added a line *_load="YES" for my module to /boot/loader.conf) to probe the PCI devices the binuptime() call always returns 1 for the seconds and a few fractions which increase slowly between calls, and the pause() call does not delay execution at all, so the driver loops forever at this point (or at least for a very long time).

Thus I'm looking for a for an alternate way to implement this, or to delay automatical loading of my module until the uptime() and pause() calls work as expected. Is it possible to define a module/driver dependency under FreeBSD so that my module is only loaded after some other module which handles the uptime()/pause() stuff?

This has been tested under FreeBSD 8.2-RELEASE for amd64, in case this matters.

Thanks in advance for any hints.

Martin

Last edited by DutchDaemon; October 31st, 2011 at 17:53. Reason: proper formatting: http://forums.freebsd.org/showthread.php?t=8816
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
First Time Installing FreeBSD have problems Dodgerules Installing & Upgrading 3 January 5th, 2011 01:38
[Solved] jails and system time nORKy General 2 November 22nd, 2010 11:53
[Solved] After long time uptime , I have to reboot to use USB Flash mfaridi Peripheral Hardware 12 August 25th, 2010 16:43
PREEMPTION on causing system to pause jcarlson General 1 March 4th, 2010 01:17
PF flags at boot time Seeker Firewalls 4 August 7th, 2009 18:27


All times are GMT +1. The time now is 11:26.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0