Re: [Geekos-devel] Re: IDE driver details
Status: Pre-Alpha
Brought to you by:
daveho
From: David H. <da...@cs...> - 2002-01-29 23:19:53
|
On Tue, Jan 29, 2002 at 04:07:52PM -0600, 'Parc' wrote: > On Tue, Jan 29, 2002 at 04:06:58PM -0800, Vishal Soni wrote: > > Use timer interrupts: I can use them if they are not going to be used by > > any other components of the kernel. This also is not a good idea because > > we frequently need to wait for 400ns in IDE -drive communication. This > > will increase the number of interrupts. Probably couple of them each > > time u try to access a sector. > > > Give me a little time and I can probably get either an RTC timer or a > 8254 secondary timer together. I believe the most common way is with > the RTC. Is the idea that you'd program a one-shot timer, and wait for it to go off? Would the resolution be sufficient? > > Second is to use loop with NOP's in it and execute it to get > > approximately a 400nsecond delay. > > For eg. if NOP takes 4 clock cycles and my clock has 100ns duty cycle I > > can get 400ns delay by putting 4 NOP in my delay loop. > > NOP gets optimized out by bochs, and some processors may do odd things. > VMWare would also not like it. Another way to do it might be to watch > the DRAM refresh status. It runs at 66Mhz, so watch it's flip-flops > for enough time. Interesting idea, although wouldn't it actually be dependent on the motherboard and processor? > > If you guys have any Ideas regarding this let me know?? I will try to > > look into Linux source reference how they handle such situations. I know > > Linux uses something called BogoMIPS. But I am not sure how it works. > > See above. Linux uses a hard coded loop of (roughly) the form: while ( count > 0 ) --count; The BogoMIPS value is the result of a test that calibrates how many iterations of this loop can execute per second. I looked at the Linux BogoMIPS code, and it's pretty hairy. So, I hacked something similar into timer.c; basically, it runs a similar loop, and determines how many iterations occur in one timer tick. The patch is attached to this email. (I'm going to commit it, so you can also just cvs update.) I haven't actually written the delay function yet, since I want to see whether it works on real hardware. (It seems to be pretty stable in Bochs; on my 450 MHz Ultra 60 it can execute 1464 iterations of the loop in one tick :-) I also need to write the loop in assembly so the same code gets executed in the delay function and the timing function. -Dave |