Re: CFT: Graphics support for /boot/loader

2009-02-11 Thread Alex Dupre

Oliver Fromme ha scritto:

The problem is related to the fact that a 64bit kernel
cannot use VESA BIOS functions.  You should be able to
use standard VGA modes though, which don't require VESA
support.


Actually I cannot see any splash screen on amd64, at least on the 
machines I tried (most with ATI ES1000 cards), with a 320x200x8 bitmap. 
No problems with i386 (on the same machines).


--
Alex Dupre
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: CFT: Graphics support for /boot/loader

2009-02-11 Thread Oliver Fromme

Alex Dupre wrote:
  Oliver Fromme ha scritto:
   The problem is related to the fact that a 64bit kernel
   cannot use VESA BIOS functions.  You should be able to
   use standard VGA modes though, which don't require VESA
   support.
  
  Actually I cannot see any splash screen on amd64, at least on the 
  machines I tried (most with ATI ES1000 cards), with a 320x200x8 bitmap. 
  No problems with i386 (on the same machines).

Yeah, my fingers were faster than my brain.  The current
syscons code cannot switch modes (no matter if VESA or
standard VGA) if there is no BIOS support.

It probably makes sense to let the boot loader set up
graphics mode (including VESA support), so it is already
active when the kernel comes up.  Then the kernel will
only have to deal with the frame buffer, not with the BIOS.
That will work on both i386 and amd64 platforms.  The only
drawback is that the mode cannot be changed by the kernel
once it is running, i.e. you have to stay in that mode
till reboot.

That solution requires support by the loader and by
syscons.  It is my plan to look into that, as soon as the
basic graphics support in the loader is finished.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH  Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

[...]  one observation we can make here is that Python makes
an excellent pseudocoding language, with the wonderful attribute
that it can actually be executed.  --  Bruce Eckel
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


generalizing fd allocation code to id allocation

2009-02-11 Thread Andriy Gapon

Guys,

anybody has ideas (or code) for generalizing code in
sys/kern/kern_descrip.c for managing fd-s (small integer numbers)?

I mean divorcing that code from filedesc and making it re-usable
wherever we need some (constrained) id allocation.
By constrained I mean that either ids are allocated from a sufficiently
small limited pool or it is desirable to keep ids at small values.

I needed this in a small driver that I am slowly writing and here's some
bits from it:

#define NDSLOTTYPE  uint64_t
#define NDSLOTSIZE  sizeof(NDSLOTTYPE)
#define NDENTRIES   (NDSLOTSIZE * __CHAR_BIT)
#define NDSLOT(x)   ((x) / NDENTRIES)
#define NDBIT(x)((NDSLOTTYPE)1  ((x) % NDENTRIES))
#define NDSLOTS(x)  (((x) + NDENTRIES - 1) / NDENTRIES)
...
/* XXX ugly */
NDSLOTTYPE host_addr_map[NDSLOTS(sizeof(uint8_t) * __CHAR_BIT)];
...
static uint8_t alloc_host_addr(struct heci_softc *sc)
{
static const int maxoff = sizeof(sc-host_addr_map) /
sizeof(sc-host_addr_map[0]);
NDSLOTTYPE *map = sc-host_addr_map;
int off;

for (off = 0; off  maxoff; ++off) {
if (map[off] != ~0UL) {
uint8_t addr = off * NDENTRIES + ffsl(~map[off])
- 1;
map[NDSLOT(addr)] |= NDBIT(addr);
return (addr);
}
}

/* XXX what to return if all addresses are in use? */
/* use the fact that zero is a reserved address */
return 0;
}

static void
release_host_addr(struct heci_softc *sc, uint8_t addr)
{
NDSLOTTYPE *map = sc-host_addr_map;
if (!(map[NDSLOT(addr)]  NDBIT(addr))) /* XXX make KASSERT? */
device_printf(sc-dev, release for unused host addr
0x%02x\n, addr);
map[NDSLOT(addr)] = ~NDBIT(addr);
}


Essentially this is almost a copy/paste.


-- 
Andriy Gapon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: generalizing fd allocation code to id allocation

2009-02-11 Thread Andriy Gapon

My nose has just been rubbed into alloc_unr(9) :)
Thanks, Roman!

on 11/02/2009 14:53 Andriy Gapon said the following:
 Guys,
 
 anybody has ideas (or code) for generalizing code in
 sys/kern/kern_descrip.c for managing fd-s (small integer numbers)?
 
 I mean divorcing that code from filedesc and making it re-usable
 wherever we need some (constrained) id allocation.
 By constrained I mean that either ids are allocated from a sufficiently
 small limited pool or it is desirable to keep ids at small values.
 
 I needed this in a small driver that I am slowly writing and here's some
 bits from it:
 
 #define NDSLOTTYPE  uint64_t
 #define NDSLOTSIZE  sizeof(NDSLOTTYPE)
 #define NDENTRIES   (NDSLOTSIZE * __CHAR_BIT)
 #define NDSLOT(x)   ((x) / NDENTRIES)
 #define NDBIT(x)((NDSLOTTYPE)1  ((x) % NDENTRIES))
 #define NDSLOTS(x)  (((x) + NDENTRIES - 1) / NDENTRIES)
 ...
 /* XXX ugly */
 NDSLOTTYPE host_addr_map[NDSLOTS(sizeof(uint8_t) * __CHAR_BIT)];
 ...
 static uint8_t alloc_host_addr(struct heci_softc *sc)
 {
 static const int maxoff = sizeof(sc-host_addr_map) /
 sizeof(sc-host_addr_map[0]);
 NDSLOTTYPE *map = sc-host_addr_map;
 int off;
 
 for (off = 0; off  maxoff; ++off) {
 if (map[off] != ~0UL) {
 uint8_t addr = off * NDENTRIES + ffsl(~map[off])
 - 1;
 map[NDSLOT(addr)] |= NDBIT(addr);
 return (addr);
 }
 }
 
 /* XXX what to return if all addresses are in use? */
 /* use the fact that zero is a reserved address */
 return 0;
 }
 
 static void
 release_host_addr(struct heci_softc *sc, uint8_t addr)
 {
 NDSLOTTYPE *map = sc-host_addr_map;
 if (!(map[NDSLOT(addr)]  NDBIT(addr))) /* XXX make KASSERT? */
 device_printf(sc-dev, release for unused host addr
 0x%02x\n, addr);
 map[NDSLOT(addr)] = ~NDBIT(addr);
 }
 
 
 Essentially this is almost a copy/paste.
 
 


-- 
Andriy Gapon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: generalizing fd allocation code to id allocation

2009-02-11 Thread Hans Petter Selasky
On Wednesday 11 February 2009, Andriy Gapon wrote:
 My nose has just been rubbed into alloc_unr(9) :)
 Thanks, Roman!

The only problem about alloc_unr() is that you cannot allocate multiple 
contiguous units?

--HPS
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: CFT: Graphics support for /boot/loader

2009-02-11 Thread Rink Springer
On Wed, Feb 11, 2009 at 01:00:58PM +0100, Oliver Fromme wrote:
 It probably makes sense to let the boot loader set up
 graphics mode (including VESA support), so it is already
 active when the kernel comes up.  Then the kernel will
 only have to deal with the frame buffer, not with the BIOS.
 That will work on both i386 and amd64 platforms.  The only
 drawback is that the mode cannot be changed by the kernel
 once it is running, i.e. you have to stay in that mode
 till reboot.

FWIW, this is exactly what FreeBSD/xbox does; the boot loader is
responsible for setting up the video mode, and all it does is remap the
framebuffer to a more sensible location (the way to do this is just
writing to a register which is the same for any Xbox, and most
bootloaders set the framebuffer to 4MB, which is a bit much for
640x480x16M especially if your machine only has 64MB of memory :-)

 That solution requires support by the loader and by
 syscons.  It is my plan to look into that, as soon as the
 basic graphics support in the loader is finished.

I think that is a good approach. Go for it!

Regards,

-- 
Rink P.W. Springer- http://rink.nu
Chance favours the prepared mind
- Penn
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: a little bit of c++ in kernel [module]

2009-02-11 Thread Andriy Gapon
on 10/02/2009 22:43 Aniruddha Bohra said the following:
 You can see Click: http://read.cs.ucla.edu/click/
 It does not  run on FreeBSD 4.
 I have an old diff which builds on the work by Marko Zec and Bruce
 Simpson, that allows me to load the click module.
 http://www.cs.rutgers.edu/~bohra/click-1.5.0.diff
 

Aniruddha,

thank you very much for the feedback!
I looked through the code and the patch and I see the following:

1. options -fpermissive -fno-exceptions -fno-rtti are passed to c++ compiler
2. there are new/delete implementations that use kernel malloc

I think that #1 means that there are no exceptions, (non-trivial)
dynamic_cast and typeid for kernel c++ code.

The questions that I have left:

1. do you use any global/static objects with constructors? did you have
to write any code to call on those constructors when the module is loaded?
2. did you have to write any other run-time support code or platform
glue code (besides new/delete)?
3. I assume virtual inheritance can be used in kernel code? do you use it?

Thank you again!

-- 
Andriy Gapon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


understanding of PTD symbol

2009-02-11 Thread Mehul Chadha
Hello all,
   I am having doubts in understanding the usage of the
symbol PTD. Could anyone pls explain the usage of PTD in the FreeBSD
kernel??

In pmap_growkernel when we execute the following instruction wht is
returned by pdir_pde ? Is it the physical address of a page table for
KVA addressing??

   while (pdir_pde(PTD, kernel_vm_end))

When I used objdump on the kernel executable i found the address of
PTD symbol to be 0xBFEFF000 , I could not understand this , as in a
virtual memory with 1G/3G split the kernel addressing must be between
the addresses 0xC000 and 0x.

Regards,
Mehul
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


userland driver?

2009-02-11 Thread Andriy Gapon

has anybody tried anything in the area of userland drivers on FreeBSD?
I mean a driver for something sufficiently simple and standalone and not
driven by interrupts. E.g. some sort of a watchdog driver that simply
reads/writes some io registers from time to time.

Brute-force and a very bad way is to go through /dev/mem, /dev/io,
/dev/pci, but I am thinking about something that would allow to plug
into newbus framework from userland.

-- 
Andriy Gapon
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: taskqueue (9)

2009-02-11 Thread John Baldwin
On Tuesday 10 February 2009 3:21:49 pm Alexej Sokolov wrote:
 Hello,
 the structure task(9) contain field ta_priority. Which role plays this
 priority if the task will wake up for run.
 Or it is used only for order of  task in waitqueue while pending ?

It is solely used to order requests within the queue.

-- 
John Baldwin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: generalizing fd allocation code to id allocation

2009-02-11 Thread Brooks Davis
On Wed, Feb 11, 2009 at 02:25:45PM +0100, Hans Petter Selasky wrote:
 On Wednesday 11 February 2009, Andriy Gapon wrote:
  My nose has just been rubbed into alloc_unr(9) :)
  Thanks, Roman!
 
 The only problem about alloc_unr() is that you cannot allocate multiple 
 contiguous units?

You might want rman for that.  The thing I would like to see alloc_urn()
grow is that ability to request a particular value so we could use it in
the ifnet cloning code.

-- Brooks


pgplbtFU5BJU5.pgp
Description: PGP signature


Re: generalizing fd allocation code to id allocation

2009-02-11 Thread David Schultz
On Wed, Feb 11, 2009, Hans Petter Selasky wrote:
 On Wednesday 11 February 2009, Andriy Gapon wrote:
  My nose has just been rubbed into alloc_unr(9) :)
  Thanks, Roman!
 
 The only problem about alloc_unr() is that you cannot allocate multiple 
 contiguous units?

Both Solaris' vmem(9) and NetBSD's extent(9) can do this...
might be worth looking into.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: a little bit of c++ in kernel [module]

2009-02-11 Thread Aniruddha Bohra
On Wed, Feb 11, 2009 at 8:25 AM, Andriy Gapon a...@icyb.net.ua wrote:
 on 10/02/2009 22:43 Aniruddha Bohra said the following:
 You can see Click: http://read.cs.ucla.edu/click/
 It does not  run on FreeBSD 4.
 I have an old diff which builds on the work by Marko Zec and Bruce
 Simpson, that allows me to load the click module.
 http://www.cs.rutgers.edu/~bohra/click-1.5.0.diff

 1. options -fpermissive -fno-exceptions -fno-rtti are passed to c++ compiler
 2. there are new/delete implementations that use kernel malloc

 I think that #1 means that there are no exceptions, (non-trivial)
 dynamic_cast and typeid for kernel c++ code.

Correct.

 1. do you use any global/static objects with constructors? did you have
 to write any code to call on those constructors when the module is loaded?

Not sure about this one. But AFAIK, there are no global static objects
with constructors in Click code.
There is one router object that is always initialized and it is
updated by writing to the clickfs file system.
The other objects are created with new.

 2. did you have to write any other run-time support code or platform
 glue code (besides new/delete)?

 Apart from the new and delete, I think the other things were the
pseudofs code to initialize the file system,
the locks in include/click/sync.hh, the glue code in atomic.hh.


 3. I assume virtual inheritance can be used in kernel code? do you use it?

Yes. For example, all objects inherit from Element and that defines
virtual functions. (include/click/element.hh)

Hope this helps.

Aniruddha
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: understanding of PTD symbol

2009-02-11 Thread Mark Tinguely

  Hello all,
 I am having doubts in understanding the usage of the
  symbol PTD. Could anyone pls explain the usage of PTD in the FreeBSD
  kernel??

  In pmap_growkernel when we execute the following instruction wht is
  returned by pdir_pde ? Is it the physical address of a page table for
  KVA addressing??

 while (pdir_pde(PTD, kernel_vm_end))

  When I used objdump on the kernel executable i found the address of
  PTD symbol to be 0xBFEFF000 , I could not understand this , as in a
  virtual memory with 1G/3G split the kernel addressing must be between
  the addresses 0xC000 and 0x.

  Regards,
  Mehul

On the i386/amd64, the page table sits just below the kernel virtual memory. 
The recursive virtual address reference to the page table is inside this 
address.

Assume i386 with 4 byte pointers and 4GB virtual address space with the 3GB
user vm and 1GB kernel vm:

the PTmap will start at 0xbfc0 (which is one 4MB entry below the KVA).

the PTD page directory descripters for the page table descripter will be
0xdeff000 which is 767 4K entries into the page table. Note: 768 is the
3G mark, so 767 is one less than 3/4 into the page table.

PTDpde is the page table descriptor the the page table. It is PTD + 767 * 4

I found it easier to draw the various layouts and the page table itself.
The i386 in 32 bit mode is 10 bits for the page directory, 10 bits for the
page table and 12 bits for the physical page. The ARM processor is funner
with 12/8/12 bits.

--Mark Tinguely.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: a little bit of c++ in kernel [module]

2009-02-11 Thread Christoph Mallon

Aniruddha Bohra schrieb:

On Wed, Feb 11, 2009 at 8:25 AM, Andriy Gapon a...@icyb.net.ua wrote:

on 10/02/2009 22:43 Aniruddha Bohra said the following:

You can see Click: http://read.cs.ucla.edu/click/
It does not  run on FreeBSD 4.
I have an old diff which builds on the work by Marko Zec and Bruce
Simpson, that allows me to load the click module.
http://www.cs.rutgers.edu/~bohra/click-1.5.0.diff

1. options -fpermissive -fno-exceptions -fno-rtti are passed to c++ compiler
2. there are new/delete implementations that use kernel malloc

I think that #1 means that there are no exceptions, (non-trivial)
dynamic_cast and typeid for kernel c++ code.


Correct.


That's a pity. Lack of exceptions negates some major benefits of C++.


1. do you use any global/static objects with constructors? did you have
to write any code to call on those constructors when the module is loaded?


Not sure about this one. But AFAIK, there are no global static objects
with constructors in Click code.
There is one router object that is always initialized and it is
updated by writing to the clickfs file system.
The other objects are created with new.


2. did you have to write any other run-time support code or platform
glue code (besides new/delete)?


 Apart from the new and delete, I think the other things were the
pseudofs code to initialize the file system,
the locks in include/click/sync.hh, the glue code in atomic.hh.



3. I assume virtual inheritance can be used in kernel code? do you use it?


Virtual inheritence needs no support from the outside, so it is available.


Yes. For example, all objects inherit from Element and that defines
virtual functions. (include/click/element.hh)


Virtual inheritance is something completely different than virtual methods.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: a little bit of c++ in kernel [module]

2009-02-11 Thread Bruce Cran
On Wed, 11 Feb 2009 22:51:02 +0100
Christoph Mallon christoph.mal...@gmx.de wrote:

 Aniruddha Bohra schrieb:
  On Wed, Feb 11, 2009 at 8:25 AM, Andriy Gapon a...@icyb.net.ua
  wrote:
  on 10/02/2009 22:43 Aniruddha Bohra said the following:
  You can see Click: http://read.cs.ucla.edu/click/
  It does not  run on FreeBSD 4.
  I have an old diff which builds on the work by Marko Zec and Bruce
  Simpson, that allows me to load the click module.
  http://www.cs.rutgers.edu/~bohra/click-1.5.0.diff
  1. options -fpermissive -fno-exceptions -fno-rtti are passed to
  c++ compiler 2. there are new/delete implementations that use
  kernel malloc
 
  I think that #1 means that there are no exceptions, (non-trivial)
  dynamic_cast and typeid for kernel c++ code.
  
  Correct.
 
 That's a pity. Lack of exceptions negates some major benefits of C++.
 
  1. do you use any global/static objects with constructors? did you
  have to write any code to call on those constructors when the
  module is loaded?
  
  Not sure about this one. But AFAIK, there are no global static
  objects with constructors in Click code.
  There is one router object that is always initialized and it is
  updated by writing to the clickfs file system.
  The other objects are created with new.
  
  2. did you have to write any other run-time support code or
  platform glue code (besides new/delete)?
  
   Apart from the new and delete, I think the other things were the
  pseudofs code to initialize the file system,
  the locks in include/click/sync.hh, the glue code in atomic.hh.
  
  
  3. I assume virtual inheritance can be used in kernel code? do you
  use it?
 
 Virtual inheritence needs no support from the outside, so it is
 available.
 
  Yes. For example, all objects inherit from Element and that
  defines virtual functions. (include/click/element.hh)
 
 Virtual inheritance is something completely different than virtual
 methods. 

Microsoft has an overview of using C++ in kernel drivers at
http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx .  It sounds
like the situation on FreeBSD may be somewhat similar.

-- 
Bruce Cran
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: a little bit of c++ in kernel [module]

2009-02-11 Thread David Schultz
On Wed, Feb 11, 2009, Bruce Cran wrote:
 On Wed, 11 Feb 2009 22:51:02 +0100
 Christoph Mallon christoph.mal...@gmx.de wrote:
 
  Aniruddha Bohra schrieb:
   On Wed, Feb 11, 2009 at 8:25 AM, Andriy Gapon a...@icyb.net.ua
   wrote:
   on 10/02/2009 22:43 Aniruddha Bohra said the following:
   You can see Click: http://read.cs.ucla.edu/click/
   It does not  run on FreeBSD 4.
   I have an old diff which builds on the work by Marko Zec and Bruce
   Simpson, that allows me to load the click module.
   http://www.cs.rutgers.edu/~bohra/click-1.5.0.diff
   1. options -fpermissive -fno-exceptions -fno-rtti are passed to
   c++ compiler 2. there are new/delete implementations that use
   kernel malloc
  
   I think that #1 means that there are no exceptions, (non-trivial)
   dynamic_cast and typeid for kernel c++ code.
   
   Correct.
  
  That's a pity. Lack of exceptions negates some major benefits of C++.
  
   1. do you use any global/static objects with constructors? did you
   have to write any code to call on those constructors when the
   module is loaded?
   
   Not sure about this one. But AFAIK, there are no global static
   objects with constructors in Click code.
   There is one router object that is always initialized and it is
   updated by writing to the clickfs file system.
   The other objects are created with new.
   
   2. did you have to write any other run-time support code or
   platform glue code (besides new/delete)?
   
Apart from the new and delete, I think the other things were the
   pseudofs code to initialize the file system,
   the locks in include/click/sync.hh, the glue code in atomic.hh.
   
   
   3. I assume virtual inheritance can be used in kernel code? do you
   use it?
  
  Virtual inheritence needs no support from the outside, so it is
  available.
  
   Yes. For example, all objects inherit from Element and that
   defines virtual functions. (include/click/element.hh)
  
  Virtual inheritance is something completely different than virtual
  methods. 
 
 Microsoft has an overview of using C++ in kernel drivers at
 http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx .  It sounds
 like the situation on FreeBSD may be somewhat similar.

FreeBSD doesn't support loading kernel code and data into pageable
memory like Windows does, so a lot of the paging-related problems
they're talking about aren't issues for us.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org