5 #include <ipxe/refcnt.h>
6 #include <ipxe/process.h>
12 * "Hello World" data source
18 struct 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 intf_shutdown ( &hw->xfer, rc );
26 process_del ( &hw->process );
29 static void hw_step ( struct hw *hw ) {
32 if ( xfer_window ( &hw->xfer ) ) {
33 rc = xfer_deliver_raw ( &hw->xfer, hw_msg, sizeof ( hw_msg ) );
34 hw_finished ( hw, rc );
38 static struct interface_operation hw_xfer_operations[] = {
39 INTF_OP ( xfer_window_changed, struct hw *, hw_step ),
40 INTF_OP ( intf_close, struct hw *, hw_finished ),
43 static struct interface_descriptor hw_xfer_desc =
44 INTF_DESC ( struct hw, xfer, hw_xfer_operations );
46 static struct process_descriptor hw_process_desc =
47 PROC_DESC_ONCE ( struct hw, process, hw_step );
49 static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
52 /* Allocate and initialise structure */
53 hw = zalloc ( sizeof ( *hw ) );
56 ref_init ( &hw->refcnt, NULL );
57 intf_init ( &hw->xfer, &hw_xfer_desc, &hw->refcnt );
58 process_init ( &hw->process, &hw_process_desc, &hw->refcnt );
60 /* Attach parent interface, mortalise self, and return */
61 intf_plug_plug ( &hw->xfer, xfer );
62 ref_put ( &hw->refcnt );
66 struct uri_opener hw_uri_opener __uri_opener = {