iPXE
sync.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 *
19 * You can also choose to distribute this program under the terms of
20 * the Unmodified Binary Distribution Licence (as given in the file
21 * COPYING.UBDL), provided that you have satisfied its requirements.
22 */
23
24FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25FILE_SECBOOT ( PERMITTED );
26
27#include <stddef.h>
28#include <ipxe/job.h>
29#include <ipxe/monojob.h>
30#include <ipxe/pending.h>
31#include <usr/sync.h>
32
33/** @file
34 *
35 * Wait for pending operations to complete
36 *
37 */
38
39/**
40 * Report progress
41 *
42 * @v intf Interface
43 * @v progress Progress report to fill in
44 * @ret ongoing_rc Ongoing job status code (if known)
45 */
46static int sync_progress ( struct interface *intf,
47 struct job_progress *progress __unused ) {
48
49 /* Terminate successfully if no pending operations remain */
50 if ( ! have_pending() )
51 intf_close ( intf, 0 );
52
53 return 0;
54}
55
56/** Synchroniser interface operations */
59};
60
61/** Synchroniser interface descriptor */
64
65/** Synchroniser */
67
68/**
69 * Wait for pending operations to complete
70 *
71 * @v timeout Timeout period, in ticks (0=indefinite)
72 * @ret rc Return status code
73 */
74int sync ( unsigned long timeout ) {
75
76 /* Attach synchroniser and wait for completion */
78 return monojob_wait ( NULL, timeout );
79}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
void timeout(int)
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition interface.c:250
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition interface.c:108
#define INTF_DESC_PURE(operations)
Define an object interface descriptor for a pure-interface object.
Definition interface.h:116
#define INTF_INIT(descriptor)
Initialise a static object interface.
Definition interface.h:218
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition interface.h:33
Job control interfaces.
struct interface monojob
Definition monojob.c:57
int monojob_wait(const char *string, unsigned long timeout)
Wait for single foreground job to complete.
Definition monojob.c:82
Single foreground job.
Pending operations.
static int have_pending(void)
Check if any operations are pending.
Definition pending.h:36
An object interface descriptor.
Definition interface.h:56
An object interface operation.
Definition interface.h:18
An object interface.
Definition interface.h:125
Job progress.
Definition job.h:16
int sync(unsigned long timeout)
Wait for pending operations to complete.
Definition sync.c:74
static struct interface_descriptor sync_intf_desc
Synchroniser interface descriptor.
Definition sync.c:62
static int sync_progress(struct interface *intf, struct job_progress *progress __unused)
Report progress.
Definition sync.c:46
static struct interface_operation sync_intf_op[]
Synchroniser interface operations.
Definition sync.c:57
static struct interface sync_intf
Synchroniser.
Definition sync.c:66
Wait for pending operations to complete.