Skip to contentSkip to conversation

Generic VESA framebuffer driver and Video card BOOT?

DISCUSSION Andi Kleen 6 participants 11 messages Oct 14, 2004 – Oct 20, 2004 1 message not in the archive Framebuffer layer

lore
Share & tools
lore

Andi Kleen

author
#1 lore raw
In reply to a message not in the archive
Quoted 2 lines · Kendall Bennett

So what do you guys think?

How big is the module with emulator etc.?

Normally putting such an emulator into kernel space doesn't sound very attractive, but if it's small enough it can be perhaps considered. Still it might be better to do it in user space.

-Andi

#2 lore raw
Quoted 5 lines · Andi Kleen
Quoted 2 lines · Kendall Bennett

So what do you guys think?

How big is the module with emulator etc.?

About 150K compiled on x86 (before linking so that has symbol information etc in it).

Quoted 3 lines

Normally putting such an emulator into kernel space doesn't sound very attractive, but if it's small enough it can be perhaps considered. Still it might be better to do it in user space.

It is small, but for the purposes we need it for it wasn't possible to put the code into user space. We thought about keeping it in user space but unfortunately the code is needed when the framebuffer console driver initialises which is very early in the boot sequence. So unless there is a way to spawn a user mode process that early in the boot sequence (it would have to come from the initrd image I expect) then the only option is to compile it into the kernel.

Regards,

---
Kendall Bennett
Chief Executive Officer
SciTech Software, Inc.
Phone: (530) 894 8400
http://www.scitechsoft.com

~ SciTech SNAP - The future of device driver technology! ~

#3 lore raw
Quoted 3 lines · Kendall Bennett

a way to spawn a user mode process that early in the boot sequence (it would have to come from the initrd image I expect) then the only option is to compile it into the kernel.

There is exactly that in 2.6 - the hotplug interfaces allow the kernel to fire off userspace programs. Jon Smirl (who you should definitely talk to about this stuff) has been hammering out a design for moving almost all the mode switching into user space for kernel video.

#4 lore raw
Quoted 10 lines · Alan Cox
Quoted 3 lines · Kendall Bennett

a way to spawn a user mode process that early in the boot sequence (it would have to come from the initrd image I expect) then the only option is to compile it into the kernel.

There is exactly that in 2.6 - the hotplug interfaces allow the kernel to fire off userspace programs. Jon Smirl (who you should definitely talk to about this stuff) has been hammering out a design for moving almost all the mode switching into user space for kernel video.

That is awesome! I am all for moving this outside of the kernel, as it would allow the use of ream vm86() services for VGA/VESA BIOS access on x86 and the user of the emulator for non-x86 platforms.

The only catch would be making sure this stuff is available really early in the boot sequence. As it stands right now the solution we have brings up the video almost imediately after you see the 'uncompressing kernel image' message on the serial port. The other solution of course is to get this into the boot loader which is what the AmigaOne folks did for their machines (U-Boot brings up the video). We are working with those guys to update their BIOS emulator to the latest version as the one they have doesn't work that reliably.

Anyway how do I find out more about this in 2.6?

Also I assume the code would need to end up in the initrg image, correct? Can you point me at some resources to learn more about how to get custom code into the initrd image?

Regards,

---
Kendall Bennett
Chief Executive Officer
SciTech Software, Inc.
Phone: (530) 894 8400
http://www.scitechsoft.com

~ SciTech SNAP - The future of device driver technology! ~

#5 lore raw
Quoted 3 lines · Kendall Bennett

Also I assume the code would need to end up in the initrg image, correct? Can you point me at some resources to learn more about how to get custom code into the initrd image?

Just roll whatever you want into it. Its a file system that is your initial root fs and is then swapped to appear under a file system it mounts (and finally potentially is freed).

Something like the Red Hat "mkinitrd" ought to give you a good flavour of what you can do with it.

#6 lore raw
In reply to Kendall Bennett
Quoted 26 lines · Kendall Bennett
Quoted 10 lines · Alan Cox
Quoted 3 lines · Kendall Bennett

a way to spawn a user mode process that early in the boot sequence (it would have to come from the initrd image I expect) then the only option is to compile it into the kernel.

There is exactly that in 2.6 - the hotplug interfaces allow the kernel to fire off userspace programs. Jon Smirl (who you should definitely talk to about this stuff) has been hammering out a design for moving almost all the mode switching into user space for kernel video.

That is awesome! I am all for moving this outside of the kernel, as it would allow the use of ream vm86() services for VGA/VESA BIOS access on x86 and the user of the emulator for non-x86 platforms.

The only catch would be making sure this stuff is available really early in the boot sequence. As it stands right now the solution we have brings up the video almost imediately after you see the 'uncompressing kernel image' message on the serial port. The other solution of course is to get this into the boot loader which is what the AmigaOne folks did for their machines (U-Boot brings up the video). We are working with those guys to update their BIOS emulator to the latest version as the one they have doesn't work that reliably.

Quoted 5 lines

Anyway how do I find out more about this in 2.6?

Also I assume the code would need to end up in the initrg image, correct? Can you point me at some resources to learn more about how to get custom code into the initrd image?

The plan for this in 2.6 is to first write a VGA device driver. This driver is responsible for identifying all of the VGA devices in a system and ensuring only one of them gets enabled a time. I started writing this but I haven't finished. This driver would be compiled into the kernel. I can send source if you are interested.

I have added hooks to the PCI subsystem to record the boot video device. If the VGA driver finds VGA devices other than the boot one it will generate hotplug events on them. Initramfs should contain a reset program for using X86 mode to reset these cards. To do this you need two things from the kernel: 1) a way to make sure only a single VGA device is active (VGA driver, allow you to disable the current VGA device, reset the card, restore the active VGA device) and 2) a way to get the ROM image. There is a patch in -mm that makes the ROMs visible in sysfs that should be in the kernel shortly.

So, when you first boot you have two choices, 1) use a display the boot ROM setup, such as VGAcon or PROMcon. or 2) have no display. People want this both ways. VGAcon/PROMcon will let you get output very early in the boot process.

Next the VGA driver will initialize. This will trigger user space resets using the program on initramfs. Now it is possible to use all of your displays. To control this from something like resume, the driver sets a lock that is cleared by the reset app and the end of reset. This will keep other processes out of the driver until reset is finished.

Right now I am working on a merged fbdev/DRM that supports multi-head adapters. It's turning out to be much more work than I though because neither DRM or fbdev handle multihead at the device driver level. You can get snapshots of the code at mesa3d.bkbits.net but it doesn't work right yet. This driver is designed to run after the VGAdriver has reset the hardware.

Signature · 2 lines
Jon Smirl
[email protected]
#7 lore raw

Hi Jon,

Quoted 5 lines

The plan for this in 2.6 is to first write a VGA device driver. This driver is responsible for identifying all of the VGA devices in a system and ensuring only one of them gets enabled a time. I started writing this but I haven't finished. This driver would be compiled into the kernel. I can send source if you are interested.

I am interested but I probably wouldn't have the time to look at it right now.

Quoted 11 lines

I have added hooks to the PCI subsystem to record the boot video device. If the VGA driver finds VGA devices other than the boot one it will generate hotplug events on them. Initramfs should contain a reset program for using X86 mode to reset these cards. To do this you need two things from the kernel: 1) a way to make sure only a single VGA device is active (VGA driver, allow you to disable the current VGA device, reset the card, restore the active VGA device) and 2) a way to get the ROM image. There is a patch in -mm that makes the ROMs visible in sysfs that should be in the kernel shortly.

Quoted 4 lines

So, when you first boot you have two choices, 1) use a display the boot ROM setup, such as VGAcon or PROMcon. or 2) have no display. People want this both ways. VGAcon/PROMcon will let you get output very early in the boot process.

What about non-x86 platforms such as PowerPC and MIPS embedded devices that want video (TiVo type platforms, media players etc). How would these fit into the picture? Would this require the boot loader (ie: U-Boot or whatever) to have the ability to POST the card?

Or perhaps the VideoBoot module would be a useful addition to the VGA boot driver compiled into the kernel to bring up the video card into a sane state on any system (even a dumb framebuffer linear mode) so a fully accelerated console driver in user space can take over later on?

Quoted 6 lines

Right now I am working on a merged fbdev/DRM that supports multi-head adapters. It's turning out to be much more work than I though because neither DRM or fbdev handle multihead at the device driver level. You can get snapshots of the code at mesa3d.bkbits.net but it doesn't work right yet. This driver is designed to run after the VGAdriver has reset the hardware.

Sounds interesting!

Regards,

---
Kendall Bennett
Chief Executive Officer
SciTech Software, Inc.
Phone: (530) 894 8400
http://www.scitechsoft.com

~ SciTech SNAP - The future of device driver technology! ~

-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl

#8 lore raw
Quoted 4 lines · Kendall Bennett

What about non-x86 platforms such as PowerPC and MIPS embedded devices that want video (TiVo type platforms, media players etc). How would these fit into the picture? Would this require the boot loader (ie: U-Boot or whatever) to have the ability to POST the card?

There is the assumption that whatever BIOS the device has can get up a very early console that can output critical error messages before the kernel and early user space is loaded. For example the "I can't find the kernel" or "initramfs is missing" error message. This also assumes that the BIOS can post whatever display it is using.

I'm not trying to fix the problem of getting early boot messages out of a Mac with an x86 card plugged into it. The card will work after early user space initializes. The right way to fix that would be to switch to something like LinuxBIOS and build the x86 emulator into it.

Also note that a lot of what you think are early boot messages are not really being printed out during early boot. The kernel queues printks until a console is running and then outputs them. An example of queuing is the processor initialization messages for the first processor. I believe there is a way to force messages like this to print as they occur using the BIOS on x86.

Quoted 4 lines

Or perhaps the VideoBoot module would be a useful addition to the VGA boot driver compiled into the kernel to bring up the video card into a sane state on any system (even a dumb framebuffer linear mode) so a fully accelerated console driver in user space can take over later on?

Signature · 2 lines
Jon Smirl
[email protected]
#9 lore raw

Hi!

Quoted 11 lines
Quoted 4 lines

What about non-x86 platforms such as PowerPC and MIPS embedded devices that want video (TiVo type platforms, media players etc). How would these fit into the picture? Would this require the boot loader (ie: U-Boot or whatever) to have the ability to POST the card?

There is the assumption that whatever BIOS the device has can get up a very early console that can output critical error messages before the kernel and early user space is loaded. For example the "I can't find the kernel" or "initramfs is missing" error message. This also assumes that the BIOS can post whatever display it is using.

Quoted 5 lines

I'm not trying to fix the problem of getting early boot messages out of a Mac with an x86 card plugged into it. The card will work after early user space initializes. The right way to fix that would be to switch to something like LinuxBIOS and build the x86 emulator into it.

That still does not solve resume from suspend-to-RAM. We need to post VGA there. We probably could do it late in userspace... but it makes debugging resume pretty hard.
Pavel

Signature · 2 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
#10 lore raw
In reply to Kendall Bennett
Quoted 11 lines · Kendall Bennett
Quoted 5 lines · Andi Kleen
Quoted 1 line · Kendall Bennett

So what do you guys think?

How big is the module with emulator etc.?

About 150K compiled on x86 (before linking so that has symbol information etc in it).

I searched for the code in the scitech FTP server... If this code is similar to the one found under "../obsolete/.." then it seems that the code is somewhat optimized for speed, whereas for video initialization we probably could rework it to be optimized for code size.

If the complete interpreter could fit in 64k (or something like that) then the chances of it getting into the kernel would be probably higher and could solve a lot of problems.

This is a problem I find somewhat interesting, and would be willing to give it some of my spare time...

Signature · 6 lines
Paulo Marques -  www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)

P.S. Aren't there other uses for a in-kernel x86 interpreter?
#11 lore raw
Quoted 10 lines · Paulo Marques
Quoted 4 lines
Quoted 1 line

How big is the module with emulator etc.?

About 150K compiled on x86 (before linking so that has symbol information etc in it).

I searched for the code in the scitech FTP server... If this code is similar to the one found under "../obsolete/.." then it seems that the code is somewhat optimized for speed, whereas for video initialization we probably could rework it to be optimized for code size.

No, the code is not under /obsolete/ but under /scitech/src/x86emu (well at least the x86 emulator portion is). It is active code we are using as well as sharing with the X.org server (time we did a sync actually ;-).

Quoted 3 lines

If the complete interpreter could fit in 64k (or something like that) then the chances of it getting into the kernel would be probably higher and could solve a lot of problems.

Given the nature of the problems at the fact that most machines where a real video card would be used have more than enough space to add 150K to the kernel, making it smaller would be mostly an academic exercise IMHO.

For instance the embedded machines that usually run video normally have at least 16M of memory, usually 32M or more. Mostly because once the kernel is up they do a lot of stuff that needs a ton more memory than a measly 150K, such as playing MPEG2 movies, playing MP3 files etc etc.

Although it would certainly be nice if it could be made smaller, I am not sure how much smaller it could be trimmed down to since the code was designed originally for functionality not necessarily speed. But you never know - perhaps some clever rearrangement of the code could make it smaller.

Quoted 2 lines

This is a problem I find somewhat interesting, and would be willing to give it some of my spare time...

By all means feel free to look and see what you can do. If you do make it smaller, I am sure the X.org folks would also be interested. We don't have the latest version of the emulator code on our ftp site (we are working on that) but the only difference between the code up there and the new code is a few bugs that we have fixed. The structure and functionality is identical.

Regards,

---
Kendall Bennett
Chief Executive Officer
SciTech Software, Inc.
Phone: (530) 894 8400
http://www.scitechsoft.com

~ SciTech SNAP - The future of device driver technology! ~