World.sh

2000-10-03 Thread loconet

I am makeing a script for newbies to help them upgrade there system it
isnt really pretty it mostly just a script that i made in a cuple of
hours but does the job and i was wundering if anyone could give it a try

and then email me bug/info/ etc.. or if you whant to help me then email
me saying so..
to dl goto : world-sh.sourceforge.net or
www.sourceforge.net/projects/world-sh





To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Question about -Wchar-subscripts

2000-10-03 Thread Thomas David Rivers

Robert Nordier <[EMAIL PROTECTED]> wrote:
> 
> Thomas David Rivers wrote:
> 
> > > > So why is using a "char" as an array subscript wrong?  I had always
> > > > avoided it because the compiler complained and that was good enough
> > > > for me.
> > > 
> > > Because your char value could be negative and end up referencing memory
> > > before your array start.  Mainly a problem with the ctype macros and
> > > high-ascii characters.
> > > 
> > 
> >  That's an interesting reason... any variable can be negative (well,
> >  except for the unsigned types...)  - what's so interesting about
> >  `char'?  Is it simply ctype macros that are the concern, or something
> >  "bigger"?
> 
> What's interesting about char is that it's implementation defined
> whether "plain" char is the equivalent of "signed char" or "unsigned
> char" (or even something else).
> 
> So, given an 8-bit, two's complement implementation of char, the
> statement
> 
>   char i = 128;
> 
> may cause 'i' to end up as -128 or 128, for example.
> 
> An implementation-defined value to your subscript is almost never
> useful, so this kind of behavior does warrant a warning.  You'll
> notice gcc doesn't warn if explicitly signed or unsigned chars are
> used as subscripts, as then there is no uncertainty.
> 
> --
> Robert Nordier

 Ah - yes!  That makes perfect sense... when you consider
 that `char' all alone can be signed or unsigned...

 Thanks for the explanation!

- Dave Rivers -




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Automatic updates (was Re: How long for -stable...)

2000-10-03 Thread Nate Williams

[ Culled the list way down, and moved it to -hackers ]

> We could also look into providing an "update" command or something
> which would pull either sources or binaries over from a snapshot box
> and make the process of getting up to the branch-head a lot easier.
> It's long been on my wishlist and I'm at the point where I'd be
> willing to devote some BSDi resources to both writing the software
> and setting up a build box for creating the relevant binaries on an
> ongoing basis.

Whoo hoo.  Sounds like a *great* plan!


Nate


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Making /etc/defaults/rc.conf a configuration file.

2000-10-03 Thread Brian Somers

> Hi,
> 
> With these patches, and the new tiny util 'sourceconf', we can make
> /etc/defaults/rc.conf and /etc/defaults/periodic.conf configuration
> files again, such that they can be parsed by things other than 'sh'.
[.]

Looks good to me !
-- 
Brian <[EMAIL PROTECTED]>
     
Don't _EVER_ lose your sense of humour !




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Question about -Wchar-subscripts

2000-10-03 Thread Leif Neland


- Original Message -
From: "Dan Nelson" <[EMAIL PROTECTED]>
To: "Larry Lile" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, October 03, 2000 9:49 PM
Subject: Re: Question about -Wchar-subscripts


> In the last episode (Oct 03), Larry Lile said:
> >
> > ...we get scores of warnings about using characters as subscripts
> > to an array (-Wchar-subscripts), which generates so much noise as
> > to mask real warnings burried within. Therefore, I would like to
> > suppress this warning unless someone can explain why using a char
> > as an array subscript is in any way an illegitimate thing to do.
> > As far as I can tell, getting rid of the warning by changing the
> > code would require adding a large number of frivolous casts to
> > scores of source files...
> >
> > So why is using a "char" as an array subscript wrong?  I had always
> > avoided it because the compiler complained and that was good enough
> > for me.
>
> Because your char value could be negative and end up referencing memory
> before your array start.  Mainly a problem with the ctype macros and
> high-ascii characters.
>
How about unsigned char? Could that be used for index?

Leif




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: 4.1-stable crash.

2000-10-03 Thread Dag-Erling Smorgrav

FengYue <[EMAIL PROTECTED]> writes:
> On 3 Oct 2000, Dag-Erling Smorgrav wrote:
> -> > panic messages:
> -> > ---
> -> Where are the panic messages?
> 
> Unfortunately, there is no panic messages. I compiled the kernel with
> -g (without DDB), and set the dumpdev in rc.conf.  Did I do anything
> wrong? 

The only thing I can think of is that the installed kernel is not the
one that paniced, so you are running gdb with the wrong symbol file.

> -> > Cannot access memory at address 0xce51d9b8.
> -> > (kgdb)
> -> This probably means the panic was in a KLD.
> How could I know which KLD was having the problem?  

Hard to tell; usually from context.

DES
-- 
Dag-Erling Smorgrav - [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Question about -Wchar-subscripts

2000-10-03 Thread Robert Nordier

Thomas David Rivers wrote:

> > > So why is using a "char" as an array subscript wrong?  I had always
> > > avoided it because the compiler complained and that was good enough
> > > for me.
> > 
> > Because your char value could be negative and end up referencing memory
> > before your array start.  Mainly a problem with the ctype macros and
> > high-ascii characters.
> > 
> 
>  That's an interesting reason... any variable can be negative (well,
>  except for the unsigned types...)  - what's so interesting about
>  `char'?  Is it simply ctype macros that are the concern, or something
>  "bigger"?

What's interesting about char is that it's implementation defined
whether "plain" char is the equivalent of "signed char" or "unsigned
char" (or even something else).

So, given an 8-bit, two's complement implementation of char, the
statement

char i = 128;

may cause 'i' to end up as -128 or 128, for example.

An implementation-defined value to your subscript is almost never
useful, so this kind of behavior does warrant a warning.  You'll
notice gcc doesn't warn if explicitly signed or unsigned chars are
used as subscripts, as then there is no uncertainty.

--
Robert Nordier

[EMAIL PROTECTED]
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Question about -Wchar-subscripts

2000-10-03 Thread Thomas David Rivers

> 
> In the last episode (Oct 03), Larry Lile said:
> > 
> > ...we get scores of warnings about using characters as subscripts
> > to an array (-Wchar-subscripts), which generates so much noise as
> > to mask real warnings burried within. Therefore, I would like to
> > suppress this warning unless someone can explain why using a char
> > as an array subscript is in any way an illegitimate thing to do.
> > As far as I can tell, getting rid of the warning by changing the
> > code would require adding a large number of frivolous casts to
> > scores of source files...
> > 
> > So why is using a "char" as an array subscript wrong?  I had always
> > avoided it because the compiler complained and that was good enough
> > for me.
> 
> Because your char value could be negative and end up referencing memory
> before your array start.  Mainly a problem with the ctype macros and
> high-ascii characters.
> 

 That's an interesting reason... any variable can be negative (well,
 except for the unsigned types...)  - what's so interesting about
 `char'?  Is it simply ctype macros that are the concern, or something
 "bigger"?

- Dave R. -
 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Question about -Wchar-subscripts

2000-10-03 Thread Dan Nelson

In the last episode (Oct 03), Larry Lile said:
> 
> ...we get scores of warnings about using characters as subscripts
> to an array (-Wchar-subscripts), which generates so much noise as
> to mask real warnings burried within. Therefore, I would like to
> suppress this warning unless someone can explain why using a char
> as an array subscript is in any way an illegitimate thing to do.
> As far as I can tell, getting rid of the warning by changing the
> code would require adding a large number of frivolous casts to
> scores of source files...
> 
> So why is using a "char" as an array subscript wrong?  I had always
> avoided it because the compiler complained and that was good enough
> for me.

Because your char value could be negative and end up referencing memory
before your array start.  Mainly a problem with the ctype macros and
high-ascii characters.

-- 
Dan Nelson
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Question about -Wchar-subscripts

2000-10-03 Thread Larry Lile


I was just asked a question that I really don't know what the "correct"
answer is, so here it is.

...we get scores of warnings about using characters as
subscripts to an array (-Wchar-subscripts), which generates
so much noise as to mask real warnings burried within. Therefore,
I would like to suppress this warning unless someone can explain
why using a char as an array subscript is in any way an illegitimate
thing to do. As far as I can tell, getting rid of the warning by 
changing the code would require adding a large number of frivolous
casts to scores of source files...

So why is using a "char" as an array subscript wrong?  I had always
avoided it because the compiler complained and that was good enough
for me.

Just curious.

-- 
Larry Lile
[EMAIL PROTECTED]



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Frustration with SCSI system

2000-10-03 Thread Andreas Klemm

On Wed, Sep 20, 2000 at 01:24:34PM -0700, Edward Elhauge wrote:
> OK, vinum is good. But my understanding is that you can't use vinum on
> your root partition. By Murphy's Law it always seems to be root that gets
> screwed up. And that also causes the biggest problems because then you
> have to yank the system apart and find another host disk for booting.

What about "duplicating and updating" /, /var and /usr onto a 2nd disk ?
This could be automatically done by a shellscript. You only need to 
fine tune /mirror/etc/fstab to boot from the correct disk after a
such a "backup/mirror" run 

If you install the freebsd boot manager you can even easily test
booting from the 2nd drive without having to make special settings
in the forth boot loader.

You could manage this using three disks I think

Disk:   da0 da1 da2
Fs:
+
root-fs |   s1a s1a (backup)|   |
+   |
swap|   swapswap|   |
+ swap  |
var-fs  |   s1f s1f (backup)|   |
+   |
usr-fs  |   s1g s1g (backup)|   |
+---+
vinum RAID5 |   /usr/local  |
+---+
vinum RAID5 |   /home   |
+---+

I'm not sure, maybe its even possible to put /var onto a
Vinum Software RAID-5 ..

Andreas ///

-- 
Andreas Klemm   Powered by FreeBSD SMP
Songs from our band >>64Bits<

Re: atomic operations

2000-10-03 Thread jdp

In article <[EMAIL PROTECTED]>,
Alfred Perlstein  <[EMAIL PROTECTED]> wrote:
> 
> +typedef struct { volatile int a; } atomic_t;
> +
> +#define atomic_init(p, v)do { p->a = v; } while(0)
> +#define atomic_destroy(p)do { ; } while(0)

I don't see the need for the do ... while(0) construct here.  Why not
something simpler?

#define atomic_init(p, v)   ((p)->a = (v))
#define atomic_destroy(p)   ((void)0)

Likewise for atomic_set(), which seems to do the same thing as
atomic_init().

John
-- 
  John Polstra   [EMAIL PROTECTED]
  John D. Polstra & Co., Inc.Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



RE: process scheduling quantum

2000-10-03 Thread John Baldwin


On 03-Oct-00 Zhiui Zhang wrote:
> 
> On Tue, 3 Oct 2000, John Baldwin wrote:
>> 
>> On 02-Oct-00 Zhiui Zhang wrote:
>> > 
>> > Suppose a process is scheduled to run, will it run until its quantum ends
>> > unless it calls tsleep() on his own? In other words, is it possible for a
>> > process to give up its quantum earlier without having it to do so 
>> > voluntarily? Thanks.
>> 
>> If an interrupt occurs and puts a thread on the run queue (which will have
>> higher priority than the currently running proceess) then the current
>> process will be stopped so that the interrupt thread can run.
> 
> Thanks. But I guess that you are talking about the new SMP threads.  For
> FreeBSD 4.1-Release, I am not sure this can happen. I am wondering any
> time taken by interrupts (hardware or software) will be accounted to the
> current process. If so, the process's quantum is stolen away and nothing
> useful for that process is done.

Yes, in pre-SMPng, interrupts use up part of the current process's quantum.

-- 

John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: 4.1-stable crash.

2000-10-03 Thread FengYue


On 3 Oct 2000, Dag-Erling Smorgrav wrote:

->> panic messages:
->> ---
->
->Where are the panic messages?

Unfortunately, there is no panic messages. I compiled the kernel with
-g (without DDB), and set the dumpdev in rc.conf.  Did I do anything
wrong? 

->> Cannot access memory at address 0xce51d9b8.
->> (kgdb)
->
->This probably means the panic was in a KLD.

How could I know which KLD was having the problem?  

Thanks



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: dlopen() & objc initializer...

2000-10-03 Thread jdp

In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:

> I have an ObjC shared object compiled in this way:
> 
> gcc -shared -rdynamic -o Bundle BreakTest.o SetTestCase.o -lSenFoundation 
>-lSenTestingKit
> 
> When I load this object with dlopen() the __objc_exec_class() initializer
> of the libraries's classes are called first than the objc initializers of the
> bundle shared objects (BreakTest.o and SetTestCase.o).
> Why ?

Because by specifying the needed libraries (-lSenFoundation
-lSenTestingKit) you are in effect stating that the other shared
objects depend on those libraries.  The dynamic linker initializes
the libraries before it initializes the shared objects which depend
on them.  That is almost always the correct thing to do.  Suppose for
example that BreakTest.o contains a constructor which calls a function
in libSenFoundation.  The library had better be initialized already
when that happens.

This is also the ordering used in Solaris, by the way.  From their
ld.so.1(1):

o  It calls any initialization functions provided by  the
   shared  object  dependencies.  By  default  these  are
   called in  the  reverse  order  of  the  topologically
   sorted dependencies. Should cyclic dependencies exist,
   the initialization  functions  are  called  using  the
   sorted  order  with  the  cycle removed. ldd(1) can be
   used to display the  initialization  order  of  shared
   object dependencies. See also LD_BREADTH.

I have tried a lot of different strategies for initializing shared
libraries, and the current one breaks fewer programs than any of the
others.

> Is it possible to tell the dynamic loader to call the
> BreakTest/SetTestCase objc initializer before the libs initializers
> ?

No.

> When I open an handle with dlopen() is possible to get the executable
> names/paths of the libs linked to it ?

Not directly.  But you might be able to achieve what you want by
using dladdr(3).

> Is there in elf something like the __CTOR_LIST__ ?

No, nothing that is available to application programs.

> With this example is possible to know in which libs a particular symbol
> resides ?

You might be able to look up the symbol using dlsym with RTLD_DEFAULT.
Then you could pass its address to dladdr() to find out which shared
library contained the definition.  See the notes in the BUGS section
of dladdr(3), though.

Also, you might need to specify RTLD_GLOBAL when loading the
libraries, if you use dlopen() for that.

By the way, when asking questions it is a good idea to say which
version of FreeBSD you are using.

John
-- 
  John Polstra   [EMAIL PROTECTED]
  John D. Polstra & Co., Inc.Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



RE: process scheduling quantum

2000-10-03 Thread Zhiui Zhang


On Tue, 3 Oct 2000, John Baldwin wrote:
> 
> On 02-Oct-00 Zhiui Zhang wrote:
> > 
> > Suppose a process is scheduled to run, will it run until its quantum ends
> > unless it calls tsleep() on his own? In other words, is it possible for a
> > process to give up its quantum earlier without having it to do so 
> > voluntarily? Thanks.
> 
> If an interrupt occurs and puts a thread on the run queue (which will have
> higher priority than the currently running proceess) then the current
> process will be stopped so that the interrupt thread can run.

Thanks. But I guess that you are talking about the new SMP threads.  For
FreeBSD 4.1-Release, I am not sure this can happen. I am wondering any
time taken by interrupts (hardware or software) will be accounted to the
current process. If so, the process's quantum is stolen away and nothing
useful for that process is done.

I wrote program the other day.  It read the number of context switches
done so far in a loop. If the number changes, then the process exits. In
between, it calls getpid(). I just want to see how many system calls can
be done between context switch. It turns out sometimes the number of calls
to getpid() is zero.  That is why I am asking the above question.

-Zhihui



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



dlopen() & objc initializer...

2000-10-03 Thread mirko . viviani

Ciao!

I have an ObjC shared object compiled in this way:

gcc -shared -rdynamic -o Bundle BreakTest.o SetTestCase.o -lSenFoundation 
-lSenTestingKit

When I load this object with dlopen() the __objc_exec_class() initializer
of the libraries's classes are called first than the objc initializers of the
bundle shared objects (BreakTest.o and SetTestCase.o).
Why ?

Is it possible to tell the dynamic loader to call the BreakTest/SetTestCase
objc initializer before the libs initializers ?

When I open an handle with dlopen() is possible to get the executable
names/paths of the libs linked to it ?

Is there in elf something like the __CTOR_LIST__ ?

With this example is possible to know in which libs a particular symbol
resides ?

Thanks in advance.

---
Bye,
 Mirko  <[EMAIL PROTECTED]>   (NeXTmail, MIME)
<[EMAIL PROTECTED]>




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: FreeBSD 4.x/3.x kld device driver

2000-10-03 Thread Alexander Langer

Thus spake Willem van Engen ([EMAIL PROTECTED]):

> I'd also like to use it on FreeBSD 3.x. When compiling gigadrive there,
> the
> file device_if.h can't be found. Any ideas to solve this?

This is code that is only working in FreeBSD 4.0 or greater.

You really should update if you develop drivers.
It's also much easier with the new driver-interface in 4.0 and above.

Alex


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Need some help developing my ethernet driver.

2000-10-03 Thread Alexander Langer

Thus spake Rink Springer ([EMAIL PROTECTED]):

> One final problem here now... how can I determine which I/O address FreeBSD
> is willing me to probe for the device? I cannot find it in any of the
> existing drivers... anyone?

This is done automatically.

Alex
-- 
cat: /home/alex/.sig: No such file or directory


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: FreeBSD 4.x/3.x kld device driver

2000-10-03 Thread Willem van Engen


> 
> Have a look at the simple device driver I wrote for the Linksys
> Gigadrive's front panel LEDs, etc.
> 
> http://people.freebsd.org/~msmith/gigadrive
Thanks! I think I'll be able to make a working driver with your code. 
I'd also like to use it on FreeBSD 3.x. When compiling gigadrive there,
the
file device_if.h can't be found. Any ideas to solve this?
> 
> This approach should suit you well.  I would use a single device node and
> a small set of ioctls for your control interface, as this will keep
> things simple.  You could also use a couple of sysctl nodes (this would
> make it possible to talk to it without needing a device node).
What would you suggest? I have no idea what's best.
> 
> Let me know if you want more comments on your code...
> 
> > I'm writing a device driver for FreeBSD 3.x and 4.x for the application
> > panel of the fujitsu lifebook c4110 notebook (a led, lcd and some
> > buttons). It took me some time to get a working driver (compiles on both
> > 3.x and 4.x), but it's not really clean code. I'd like to rewrite it,
> > but I can't find how to do it properly (the kernel sources don't help me
> > enough). How do I use uimove, DECLARE_MODULE, etc properly? How do I use
> > more than one device in one module?
> > Currently I use outb and inb to access the hardware resources. Should
> > newbus be used in FreeBSD 4.x?
> >
> > Another question is the architecure of the device driver. How exactly
> > should the interface to the device be? Currently, I'm thinking of three
> > devices to control the three different parts /dev/led (led), /dev/lcd
> > (lcd) and /dev/abtn (buttons). Ascii numbers should be written to/read
> > from the character devices. Is this the way to do it, or should system
> > calls be used (harder to use in shell scripts) or binary values?
> >
> > Thanks in advance.
> >
> > Willem van Engen <[EMAIL PROTECTED]>
> >
> > See the application panel project at http://willem.n3.net/fujitsu/
> >
> >
> > To Unsubscribe: send mail to [EMAIL PROTECTED]
> > with "unsubscribe freebsd-hackers" in the body of the message
> >
> 
> --
> ... every activity meets with opposition, everyone who acts has his
> rivals and unfortunately opponents also.  But not because people want
> to be opponents, rather because the tasks and relationships force
> people to take different points of view.  [Dr. Fritz Todt]
>V I C T O R Y   N O T   V E N G E A N C E
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: FreeBSD 4.x kld device driver

2000-10-03 Thread Mike Smith


Have a look at the simple device driver I wrote for the Linksys 
Gigadrive's front panel LEDs, etc. 

http://people.freebsd.org/~msmith/gigadrive

This approach should suit you well.  I would use a single device node and 
a small set of ioctls for your control interface, as this will keep 
things simple.  You could also use a couple of sysctl nodes (this would 
make it possible to talk to it without needing a device node).

Let me know if you want more comments on your code...

> I'm writing a device driver for FreeBSD 3.x and 4.x for the application
> panel of the fujitsu lifebook c4110 notebook (a led, lcd and some
> buttons). It took me some time to get a working driver (compiles on both
> 3.x and 4.x), but it's not really clean code. I'd like to rewrite it,
> but I can't find how to do it properly (the kernel sources don't help me
> enough). How do I use uimove, DECLARE_MODULE, etc properly? How do I use
> more than one device in one module?
> Currently I use outb and inb to access the hardware resources. Should
> newbus be used in FreeBSD 4.x?
> 
> Another question is the architecure of the device driver. How exactly
> should the interface to the device be? Currently, I'm thinking of three
> devices to control the three different parts /dev/led (led), /dev/lcd
> (lcd) and /dev/abtn (buttons). Ascii numbers should be written to/read
> from the character devices. Is this the way to do it, or should system
> calls be used (harder to use in shell scripts) or binary values?
> 
> Thanks in advance.
> 
> Willem van Engen <[EMAIL PROTECTED]>
> 
> See the application panel project at http://willem.n3.net/fujitsu/
> 
> 
> To Unsubscribe: send mail to [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
> 

-- 
... every activity meets with opposition, everyone who acts has his
rivals and unfortunately opponents also.  But not because people want
to be opponents, rather because the tasks and relationships force
people to take different points of view.  [Dr. Fritz Todt]
   V I C T O R Y   N O T   V E N G E A N C E




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



FreeBSD 4.x kld device driver

2000-10-03 Thread Willem van Engen

I'm writing a device driver for FreeBSD 3.x and 4.x for the application
panel of the fujitsu lifebook c4110 notebook (a led, lcd and some
buttons). It took me some time to get a working driver (compiles on both
3.x and 4.x), but it's not really clean code. I'd like to rewrite it,
but I can't find how to do it properly (the kernel sources don't help me
enough). How do I use uimove, DECLARE_MODULE, etc properly? How do I use
more than one device in one module?
Currently I use outb and inb to access the hardware resources. Should
newbus be used in FreeBSD 4.x?

Another question is the architecure of the device driver. How exactly
should the interface to the device be? Currently, I'm thinking of three
devices to control the three different parts /dev/led (led), /dev/lcd
(lcd) and /dev/abtn (buttons). Ascii numbers should be written to/read
from the character devices. Is this the way to do it, or should system
calls be used (harder to use in shell scripts) or binary values?

Thanks in advance.

Willem van Engen <[EMAIL PROTECTED]>

See the application panel project at http://willem.n3.net/fujitsu/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: Need some help developing my ethernet driver.

2000-10-03 Thread Dag-Erling Smorgrav

"Rink Springer" <[EMAIL PROTECTED]> writes:
> I am currently working on a driver for the D-Link DE620 Parallel Ethernet
> card driver. I used the if_el.c code as a base, for it appears to be a
> relatively easy driver (my driver is called dl0 BTW, for D-Link. Anyknow
> know if this conflicts somewhere?).

You might want to look at src/sys/i386/isa/if_rdp.c instead.

And yes, dl is available, though there's a header file called if_dl.h;
if your driver needs its own header file, call it if_dlreg.h.

DES
-- 
Dag-Erling Smorgrav - [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: 4.1-stable crash.

2000-10-03 Thread Dag-Erling Smorgrav

FengYue <[EMAIL PROTECTED]> writes:
> gdb -k kernel.debug /var/crash/vmcore.0
> [GDB messages...]
> This GDB was configured as "i386-unknown-freebsd"...
> IdlePTD 2863104
> initial pcb at 247960
> panicstr: page fault
> panic messages:
> ---

Where are the panic messages?

> dmesg: kvm_read: 
> ---
> #0  0xc0132df8 in boot ()
> (kgdb) where
> #0  0xc0132df8 in boot ()
> Cannot access memory at address 0xce51d9b8.
> (kgdb) 

This probably means the panic was in a KLD.

DES
-- 
Dag-Erling Smorgrav - [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: XFreeBSD Install - 4.1-RELEASE #:0 Fri Jul 28 14:30:31 GMT 2000

2000-10-03 Thread Dag-Erling Smorgrav

Loony Bomber <[EMAIL PROTECTED]> writes:
>   Given these qualifications, and the fact
> that the first router I built on a recycled 286 system (as a lark)

FreeBSD won't run on a 286 (and never has). The 286 is a 16-bit
processor, and FreeBSD is (and has always been) a 32-bit OS.

> I chose to install xfreebsd with KDE, Gnome, and some ports

There is no such thing as XFreeBSD. Maybe you mean XFree86?

>   When I finally figured
> that startx works better than xwin (or whatever xwin commands I first
> came across (logically),

startx is not the Right Way. Look for 'xdm' in /etc/ttys.

>  I was totally confounded by the fact that I now
> had 4 taskbars on the top and bottom of the screen, two hidden behind
> others.  I'm doing unorthodox things like loading KDE as a non-managed
> session in windowmanager to get my desktop approximating a single
> taskbar desktop.

Just create a .xsession file in your home directory that contains the
single line 'exec /usr/local/bin/startkde'.

>Would it be too hard to get the
> KDE and Gnome folks together with installation program coders to figure
> out an improved x-windows installation routine?

The KDE and Gnome folks have no part in this.

> The sound card didn't go in either.  Ok, so ya purposefully wanted to
> give people incentive to build their own kernels.  After all the hard
> work you put into it, I can see that you might just want to throw up
> your hands and say, "If ya can't do that, go back to whatever OS ya'
> came from."

No, but the sound drivers in 4.1 aren't dynamically loadable, and we
don't want to put too much into the GENERIC kernel. 5.0 can load the
sound drivers dynamically, and I expect 4.2 will as well.

DES
-- 
Dag-Erling Smorgrav - [EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



RE: process scheduling quantum

2000-10-03 Thread Daniel Eischen

On Tue, 3 Oct 2000, John Baldwin wrote:
> 
> On 02-Oct-00 Zhiui Zhang wrote:
> > 
> > Suppose a process is scheduled to run, will it run until its quantum ends
> > unless it calls tsleep() on his own? In other words, is it possible for a
> > process to give up its quantum earlier without having it to do so 
> > voluntarily? Thanks.
> 
> If an interrupt occurs and puts a thread on the run queue (which will have
> higher priority than the currently running proceess) then the current
> process will be stopped so that the interrupt thread can run.

Uhh, I think he wants a process to be able to willingly give up its
remaining quantum.  This is called sched_yield(2).

-- 
Dan Eischen



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: atomic operations

2000-10-03 Thread Poul-Henning Kamp

In message <005801c02d17$17efc0a0$[EMAIL PROTECTED]>, "Jan Mikk
elsen" writes:
>John Baldwin <[EMAIL PROTECTED]> wrote:
>
>>On 03-Oct-00 Jan Mikkelsen wrote:
>>> There shouldn't be a need for a loop like the one you describe for a
>simple
>>> atomic increment.
>>
>>The trick is that I want to increment and read at the same time.
>
>
>I don't know the exact semantics of atomic_cmpset_int, but it looks like a
>compare and swap operation which returns zero if the operation failed, some
>other value on success.

That is exactly what atomic_cmpset_int is for, look in 
sys/fs/devfs/devfs_devs.c
for some examples

--
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD coreteam member | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: atomic operations

2000-10-03 Thread Jan Mikkelsen

John Baldwin <[EMAIL PROTECTED]> wrote:

>On 03-Oct-00 Jan Mikkelsen wrote:
>> There shouldn't be a need for a loop like the one you describe for a
simple
>> atomic increment.
>
>The trick is that I want to increment and read at the same time.


I don't know the exact semantics of atomic_cmpset_int, but it looks like a
compare and swap operation which returns zero if the operation failed, some
other value on success.

Unless I've missed something, the basic operation of your loop can be done
(on a '486 or better) without the loop by using the xadd instruction.  Of
course, if the code needs to run on earlier processors, xadd fails and a
loop is necessary.

Jan Mikkelsen




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Internet Prepaid Card

2000-10-03 Thread Mustafa Deeb

hi all,

I'm working on building a system that will handle Internet Prepaid Cards
where the user would connect for a certain amount of time and then disconnect
ofcourse this is not implemented in Radius.

after some digging, I was able to control it through Session-Timeout 
Attribute in Radius
and some scripts that will decrement the value until it reaches 1, but still
this means I'll have to put an entry for each card in the users file along 
with another entry in
master.passwd file,  I don't if radiusd can handle that amount of entries, 
and anyways, if my password file
is more than 10k lines, that's not good.

the other approach that I'm looking into is through database,
radiusd is patched to do auth and acct from database, but not read 
configuration
I wonder if someone did this before, make radiusd read its configuration 
from a database
my aim here is to make radius read the Session-Timeout from a database

or use Oracle Radius Adapter, on and oracle database, but I couldn't find 
Session-Timeout in it too.

did somebody did this before?

Best Regards
Mustafa N. Deeb
Palnet Communications Ltd.
Technical Director



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: atomic operations

2000-10-03 Thread Alfred Perlstein

* John Baldwin <[EMAIL PROTECTED]> [001003 00:01] wrote:
> 
> On 25-Sep-00 Jan Mikkelsen wrote:
> > Kevin Mills <[EMAIL PROTECTED]> wrote:
> >>I found the atomic_* functions in , but noticed that they
> >>have no return value.  What I need is a function that increments/decrements
> >>the given value *and* returns the new value in an atomic operation.  I
> >>suppose this is possible, yes?  How would one modify the assembly to make
> >>this work?
> > 
> > 
> > Atomic decrement, in the Intel style:
> > 
> > long atomic_decrement(volatile long* address)
> > {
> >   asm {
> > mov ecx, [address]
> > mov eax, -1
> > lock xadd [ecx], eax
> > dec eax
> >   }
> >  /* Return value in EAX */
> > }
> > 
> > An untested conversion into the GNU/AT&T style:
> > 
> > long atomic_decrement(volatile long* address)
> > {
> >  asm("movl 8(%ebp),%ecx");
> >  asm("movl $-1, %eax");
> >  asm("lock xaddl %eax,(%ecx)");
> >  asm("decl %eax");
> >  /* Return value in %eax */
> > }
> 
> Uh, there is no xaddl instruction in the x86 instruction set.  There is
> a fetchadd instruction in ia64, but that doesn't help much here.  You
> can use a loop with the atomic_cmpset_* primitives though to achieve this.
> e.g.:
> 
> volatile int value;
> int save, increment;
> 
>value = 3; increment = 4;
>do {
>   save = value;
>} while (atomic_cmpset_int(&value, save, save + increment) == 0);
>foo = some_array[save + increment];
> 
> You can use this to control access to a circular buffer w/o needing a
> lock to obtain new entries for example.  This will only work with -current
> though.

Mike Smith and I discussed atomic types and the problem is that not
all arches can do all the ops we want, as a compromise we can use
macros to wrap the ops as long as we use constructors and destructors
for atomic_t.

this could use some testing/comments, my gcc+asm is terrible:

Index: atomic.h
===
RCS file: /home/ncvs/src/sys/i386/include/atomic.h,v
retrieving revision 1.12
diff -u -u -r1.12 atomic.h
--- atomic.h2000/09/06 11:21:14 1.12
+++ atomic.h2000/10/03 07:05:59
@@ -218,6 +218,31 @@
return (
atomic_cmpset_int((volatile u_int *)dst, (u_int)exp, (u_int)src));
 }
-#endif
+
+typedef struct { volatile int a; } atomic_t;
+
+#define atomic_init(p, v)  do { p->a = v; } while(0)
+#define atomic_destroy(p)  do { ; } while(0)
+#define atomic_add(p, v)   atomic_add_int(&(p->a), v)
+#define atomic_sub(p, v)   atomic_subtract_int(&(p->a), v)
+#define atomic_or(p, v)atomic_set_int(&(p->a), v)
+#define atomic_and(p, v)   atomic_clear_int(&(p->a), v)
+#define atomic_read(p) ((p)->a)
+#define atomic_set(p, v)   do { (p)->a = (v); } while(0);
+/* XXX: maybe use decl/incl ? */
+#define atomic_dec(p)  atomic_sub(&(p->a), 1)
+#define atomic_inc(p)  atomic_add(&(p->a), 1)
+
+static __inline int
+atomic_dec_and_test(volatile atomic_t *v)
+{
+   unsigned char c;
+
+   __asm __volatile("lock ; decl %0; sete %1"
+: "=m" (v->a), "=qm" (c)
+: "m" (v->a));
+   return (c != 0);
+}
+#endif /* !WANT_FUNCTIONS */
 
 #endif /* ! _MACHINE_ATOMIC_H_ */




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: atomic operations

2000-10-03 Thread John Baldwin


On 03-Oct-00 Jan Mikkelsen wrote:
> John Baldwin <[EMAIL PROTECTED]> wrote:
>>Uh, there is no xaddl instruction in the x86 instruction set.
> 
> It was introduced in the '486.  I've been using it for some years now, so I
> am confident of its existence.

Freaky.  Time for a new atomic op perhaps.

> There shouldn't be a need for a loop like the one you describe for a simple
> atomic increment.

The trick is that I want to increment and read at the same time.

> I'm pretty new to FreeBSD:  what is changing in -current which alters the
> behaviour of your code?

atomic_cmpset_* don't exist in stable, they are part of SMPng.

> Jan Mikkelsen

-- 

John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: atomic operations

2000-10-03 Thread Jan Mikkelsen

John Baldwin <[EMAIL PROTECTED]> wrote:
>Uh, there is no xaddl instruction in the x86 instruction set.

It was introduced in the '486.  I've been using it for some years now, so I
am confident of its existence.

A quick test using my example:

$ objdump -d jan.o

jan.o: file format elf32-i386

Disassembly of section .text:

 :
   0:   55  push   %ebp
   1:   89 e5   mov%esp,%ebp
   3:   8b 4d 08mov0x8(%ebp),%ecx
   6:   b8 ff ff ff ff  mov$0x,%eax
   b:   f0 0f c1 01 lock xadd %eax,(%ecx)
   f:   48  dec%eax
  10:   c9  leave
  11:   c3  ret

There shouldn't be a need for a loop like the one you describe for a simple
atomic increment.

I'm pretty new to FreeBSD:  what is changing in -current which alters the
behaviour of your code?

Jan Mikkelsen




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message