1*fc75e102Sagc /* $NetBSD: libkmod.h,v 1.1 2009/06/22 14:44:12 agc Exp $ */ 2*fc75e102Sagc 3*fc75e102Sagc /*- 4*fc75e102Sagc * Copyright (c) 2008 The NetBSD Foundation, Inc. 5*fc75e102Sagc * All rights reserved. 6*fc75e102Sagc * 7*fc75e102Sagc * Redistribution and use in source and binary forms, with or without 8*fc75e102Sagc * modification, are permitted provided that the following conditions 9*fc75e102Sagc * are met: 10*fc75e102Sagc * 1. Redistributions of source code must retain the above copyright 11*fc75e102Sagc * notice, this list of conditions and the following disclaimer. 12*fc75e102Sagc * 2. Redistributions in binary form must reproduce the above copyright 13*fc75e102Sagc * notice, this list of conditions and the following disclaimer in the 14*fc75e102Sagc * documentation and/or other materials provided with the distribution. 15*fc75e102Sagc * 16*fc75e102Sagc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17*fc75e102Sagc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18*fc75e102Sagc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19*fc75e102Sagc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20*fc75e102Sagc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*fc75e102Sagc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*fc75e102Sagc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*fc75e102Sagc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*fc75e102Sagc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*fc75e102Sagc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*fc75e102Sagc * POSSIBILITY OF SUCH DAMAGE. 27*fc75e102Sagc */ 28*fc75e102Sagc #ifndef LIBKMOD_H_ 29*fc75e102Sagc #define LIBKMOD_H_ 20090619 30*fc75e102Sagc 31*fc75e102Sagc #include <sys/module.h> 32*fc75e102Sagc 33*fc75e102Sagc #include <stdio.h> 34*fc75e102Sagc 35*fc75e102Sagc /* this struct describes the loaded modules in the kernel */ 36*fc75e102Sagc typedef struct kernel_t { 37*fc75e102Sagc size_t size; /* size of iovec array */ 38*fc75e102Sagc size_t c; /* counter during "read" operations */ 39*fc75e102Sagc struct iovec iov; /* iovecs from the modctl operation */ 40*fc75e102Sagc } kernel_t; 41*fc75e102Sagc 42*fc75e102Sagc /* this struct describes a module */ 43*fc75e102Sagc typedef struct kmod_t { 44*fc75e102Sagc char *name; /* module name */ 45*fc75e102Sagc char *class; /* module class */ 46*fc75e102Sagc char *source; /* source of module loading */ 47*fc75e102Sagc int refcnt; /* reference count */ 48*fc75e102Sagc unsigned size; /* size of binary module */ 49*fc75e102Sagc char *required; /* any pre-reqs module has */ 50*fc75e102Sagc } kmod_t; 51*fc75e102Sagc 52*fc75e102Sagc /* low level open, read, write ops */ 53*fc75e102Sagc int openkmod(kernel_t *); 54*fc75e102Sagc int readkmod(kernel_t *, kmod_t *); 55*fc75e102Sagc void freekmod(kmod_t *); 56*fc75e102Sagc int closekmod(kernel_t *); 57*fc75e102Sagc 58*fc75e102Sagc /* high-level kmod operations */ 59*fc75e102Sagc int kmodstat(const char *, FILE *); 60*fc75e102Sagc int kmodload(const char *); 61*fc75e102Sagc int kmodunload(const char *); 62*fc75e102Sagc 63*fc75e102Sagc #endif 64