From owner-freebsd-hackers Sun Oct 1 02:05:15 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id CAA28920 for hackers-outgoing; Sun, 1 Oct 1995 02:05:15 -0700 Received: from grunt.grondar.za (grunt.grondar.za [196.7.18.129]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id CAA28912 for ; Sun, 1 Oct 1995 02:05:03 -0700 Received: from grumble.grondar.za (grumble.grondar.za [196.7.18.130]) by grunt.grondar.za (8.6.12/8.6.9) with ESMTP id LAA00907 for ; Sun, 1 Oct 1995 11:04:54 +0200 Received: from localhost (localhost [127.0.0.1]) by grumble.grondar.za (8.6.12/8.6.9) with SMTP id LAA00617 for ; Sun, 1 Oct 1995 11:04:53 +0200 Message-Id: <199510010904.LAA00617@grumble.grondar.za> X-Authentication-Warning: grumble.grondar.za: Host localhost didn't use HELO protocol To: hackers@freebsd.org Subject: How to get to the hardware? Date: Sun, 01 Oct 1995 11:04:53 +0200 From: Mark Murray Sender: owner-hackers@freebsd.org Precedence: bulk Hi Kernel Boffin! This is my first foray into the High Temple of Kernel Hacking (tm), and I am desparately in deed of some guidance, please. I am working on a device (/dev/random) to give truly nasty random numbers for crypto/security use, and it is mostly going OK. I have some code written by Theodore Ts'o, and it is good stuff, but it is for the Linux kernel. Could someone please suggest to me the best way of doing the following in the FreeBSD kernel: (I am not sure I like the concept of just messing with the timer directly, and yes, I have had a look at microtime.s) The bits I do not line are the outb_p() and inb_p(). There _has_ to be a better way... #if defined (__i386__) && 0 /* * On a 386, read the high resolution timer. We assume that * this gives us 2 bits of randomness. XXX This needs * investigation. */ outb_p(0x00, 0x43); /* latch the count ASAP */ add_entropy_byte(r, inb_p(0x40), 1); add_entropy_byte(r, inb(0x40), 1); r->entropy_count += 2; if (r->entropy_count > r->bit_length) r->entropy_count = r->bit_length; #endif Thanks! M -- Mark Murray 46 Harvey Rd, Claremont, Cape Town 7700, South Africa +27 21 61-3768 GMT+0200 Finger mark@grumble.grondar.za for PGP key