[syslinux] Patch sensible callback framework

H. Peter Anvin hpa at zytor.com
Tue Apr 27 14:38:25 PDT 2010


On 04/26/2010 08:35 PM, Ayvaz, James wrote:
> This patch adds a simple callback framework.
>
> 	Modified loadfile and floadfile to look for callbacks and call them if present
>
> 	Supports multiple callbacks
>
> 	Modified com32/modules/linux.c to demonstrate functionality (it's a little more complicated than it should be just to demonstrate multiple callbacks).  Add progress argument to display a percentage indicator when loading.
>
> Example
>
> boot: linux progress
> Loading vmlinuz 100%
> Loading initrd.img 100%
>
>
> Let me know if you spot any problems.  Thanks.
>

This looks a lot better, but I think we can improve it further.

In particular:

a) let register_callback() return a callback record pointer (or NULL on 
failure).  This pointer can then be passed to unregister_callback() 
instead of doing a linear search.

b) Instead of using an integer type for the callback type, make it the 
head of a callback list (which is just exported as a normal variable.) 
First of all, it makes it easy to create new callbacks, and second, it 
means we don't have to walk the whole list of callbacks when we invoke 
it; we just walk the exact list of callbacks that we care about.

c) Make the invocation points smaller, e.g. by an callbacks_invoke() 
helper function.

d) I suspect we need to pass a few options to the callback.  In 
particular, we should have a user argument (typically a void *) which is 
passed in at register_callback() time, and probably information from the 
invocation point, e.g. the file descriptor/file pointer.

	-hpa




More information about the Syslinux mailing list