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

◆ hw_finished()

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

Definition at line 24 of file hw.c.

24  {
25  intf_shutdown ( &hw->xfer, rc );
26  process_del ( &hw->process );
27 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
struct process process
Definition: hw.c:19
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
Definition: hw.c:16
struct interface xfer
Definition: hw.c:18

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

Referenced by hw_step().

◆ hw_step()

static void hw_step ( struct hw hw)
static

Definition at line 29 of file hw.c.

29  {
30  int rc;
31 
32  if ( xfer_window ( &hw->xfer ) ) {
33  rc = xfer_deliver_raw ( &hw->xfer, hw_msg, sizeof ( hw_msg ) );
34  hw_finished ( hw, rc );
35  }
36 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Definition: hw.c:16
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:116
static const char hw_msg[]
Definition: hw.c:22
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:288
static void hw_finished(struct hw *hw, int rc)
Definition: hw.c:24
struct interface xfer
Definition: hw.c:18

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

◆ hw_open()

static int hw_open ( struct interface xfer,
struct uri *uri  __unused 
)
static

Definition at line 49 of file hw.c.

49  {
50  struct hw *hw;
51 
52  /* Allocate and initialise structure */
53  hw = zalloc ( sizeof ( *hw ) );
54  if ( ! hw )
55  return -ENOMEM;
56  ref_init ( &hw->refcnt, NULL );
59 
60  /* Attach parent interface, mortalise self, and return */
61  intf_plug_plug ( &hw->xfer, xfer );
62  ref_put ( &hw->refcnt );
63  return 0;
64 }
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
static void process_init(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process and add to process list.
Definition: process.h:161
struct process process
Definition: hw.c:19
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
static struct interface_descriptor hw_xfer_desc
Definition: hw.c:43
Definition: hw.c:16
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct refcnt refcnt
Definition: hw.c:17
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
struct interface xfer
Definition: hw.c:18
static struct process_descriptor hw_process_desc
Definition: hw.c:46
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

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

Variable Documentation

◆ hw_msg

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

Definition at line 22 of file hw.c.

Referenced by hw_step().

◆ hw_xfer_operations

struct interface_operation hw_xfer_operations[]
static
Initial value:
= {
INTF_OP ( intf_close, struct hw *, hw_finished ),
}
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:146
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
Definition: hw.c:16
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
static void hw_finished(struct hw *hw, int rc)
Definition: hw.c:24
static void hw_step(struct hw *hw)
Definition: hw.c:29

Definition at line 38 of file hw.c.

◆ hw_xfer_desc

struct interface_descriptor hw_xfer_desc
static
Initial value:
=
static struct interface_operation hw_xfer_operations[]
Definition: hw.c:38
Definition: hw.c:16
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80
struct interface xfer
Definition: hw.c:18

Definition at line 43 of file hw.c.

Referenced by hw_open().

◆ hw_process_desc

struct process_descriptor hw_process_desc
static
Initial value:
=
A process.
Definition: process.h:17
#define PROC_DESC_ONCE(object_type, process, _step)
Define a process descriptor for a process that runs only once.
Definition: process.h:97
Definition: hw.c:16
static void hw_step(struct hw *hw)
Definition: hw.c:29

Definition at line 46 of file hw.c.

Referenced by hw_open().

◆ __uri_opener

struct uri_opener hw_uri_opener __uri_opener
Initial value:
= {
.scheme = "hw",
.open = hw_open,
}
static int hw_open(struct interface *xfer, struct uri *uri __unused)
Definition: hw.c:49

Definition at line 66 of file hw.c.