iPXE
Data Structures | Functions | Variables
hw.c File Reference

"Hello World" data source More...

#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/refcnt.h>
#include <ipxe/process.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>

Go to the source code of this file.

Data Structures

struct  hw

Functions

static void hw_finished (struct hw *hw, int rc)
static void hw_step (struct hw *hw)
static int hw_open (struct interface *xfer, struct uri *uri __unused)

Variables

static const char hw_msg [] = "Hello world!\n"
static struct interface_operation hw_xfer_operations []
static struct interface_descriptor hw_xfer_desc
static struct process_descriptor hw_process_desc
struct uri_opener hw_uri_opener __uri_opener

Detailed Description

"Hello World" data source

Definition in file hw.c.


Function Documentation

static void hw_finished ( struct hw hw,
int  rc 
) [static]

Definition at line 24 of file hw.c.

References intf_shutdown(), hw::process, process_del(), and hw::xfer.

Referenced by hw_step().

                                                  {
        intf_shutdown ( &hw->xfer, rc );
        process_del ( &hw->process );
}
static void hw_step ( struct hw hw) [static]

Definition at line 29 of file hw.c.

References hw_finished(), hw_msg, rc, hw::xfer, xfer_deliver_raw(), and xfer_window().

                                      {
        int rc;

        if ( xfer_window ( &hw->xfer ) ) {
                rc = xfer_deliver_raw ( &hw->xfer, hw_msg, sizeof ( hw_msg ) );
                hw_finished ( hw, rc );
        }
}
static int hw_open ( struct interface xfer,
struct uri *uri  __unused 
) [static]

Definition at line 49 of file hw.c.

References ENOMEM, intf_init(), intf_plug_plug(), NULL, hw::process, process_init(), ref_init, ref_put, hw::refcnt, hw::xfer, and zalloc().

                                                                        {
        struct hw *hw;

        /* Allocate and initialise structure */
        hw = zalloc ( sizeof ( *hw ) );
        if ( ! hw )
                return -ENOMEM;
        ref_init ( &hw->refcnt, NULL );
        intf_init ( &hw->xfer, &hw_xfer_desc, &hw->refcnt );
        process_init ( &hw->process, &hw_process_desc, &hw->refcnt );

        /* Attach parent interface, mortalise self, and return */
        intf_plug_plug ( &hw->xfer, xfer );
        ref_put ( &hw->refcnt );
        return 0;
}

Variable Documentation

const char hw_msg[] = "Hello world!\n" [static]

Definition at line 22 of file hw.c.

Referenced by hw_step().

Initial value:
 {
        INTF_OP ( xfer_window_changed, struct hw *, hw_step ),
        INTF_OP ( intf_close, struct hw *, hw_finished ),
}

Definition at line 38 of file hw.c.

Initial value:

Definition at line 43 of file hw.c.

Initial value:

Definition at line 46 of file hw.c.

struct uri_opener hw_uri_opener __uri_opener
Initial value:
 {
        .scheme = "hw",
        .open = hw_open,
}

Definition at line 66 of file hw.c.