5 #include <gpxe/refcnt.h>
6 #include <gpxe/process.h>
12 * "Hello World" data source
18 struct xfer_interface xfer
;
19 struct process process
;
22 static const char hw_msg
[] = "Hello world!\n";
24 static void hw_finished ( struct hw
*hw
, int rc
) {
25 xfer_nullify ( &hw
->xfer
);
26 xfer_close ( &hw
->xfer
, rc
);
27 process_del ( &hw
->process
);
30 static void hw_xfer_close ( struct xfer_interface
*xfer
, int rc
) {
31 struct hw
*hw
= container_of ( xfer
, struct hw
, xfer
);
33 hw_finished ( hw
, rc
);
36 static struct xfer_interface_operations hw_xfer_operations
= {
37 .close
= hw_xfer_close
,
38 .vredirect
= ignore_xfer_vredirect
,
39 .seek
= ignore_xfer_seek
,
40 .window
= unlimited_xfer_window
,
41 .deliver_iob
= xfer_deliver_as_raw
,
42 .deliver_raw
= ignore_xfer_deliver_raw
,
45 static void hw_step ( struct process
*process
) {
46 struct hw
*hw
= container_of ( process
, struct hw
, process
);
49 if ( xfer_window ( &hw
->xfer
) ) {
50 rc
= xfer_deliver_raw ( &hw
->xfer
, hw_msg
, sizeof ( hw_msg
) );
51 hw_finished ( hw
, rc
);
55 static int hw_open ( struct xfer_interface
*xfer
, struct uri
*uri __unused
) {
58 /* Allocate and initialise structure */
59 hw
= zalloc ( sizeof ( *hw
) );
62 xfer_init ( &hw
->xfer
, &hw_xfer_operations
, &hw
->refcnt
);
63 process_init ( &hw
->process
, hw_step
, &hw
->refcnt
);
65 /* Attach parent interface, mortalise self, and return */
66 xfer_plug_plug ( &hw
->xfer
, xfer
);
67 ref_put ( &hw
->refcnt
);
71 struct uri_opener hw_uri_opener __uri_opener
= {