fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
at master 69 lines 2.5 kB view raw
1/***************************************************************************** 2 * pce * 3 *****************************************************************************/ 4 5/***************************************************************************** 6 * File name: src/devices/device.h * 7 * Created: 2005-12-08 by Hampa Hug <hampa@hampa.ch> * 8 * Copyright: (C) 2005-2009 Hampa Hug <hampa@hampa.ch> * 9 *****************************************************************************/ 10 11/***************************************************************************** 12 * This program is free software. You can redistribute it and / or modify it * 13 * under the terms of the GNU General Public License version 2 as published * 14 * by the Free Software Foundation. * 15 * * 16 * This program is distributed in the hope that it will be useful, but * 17 * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 * Public License for more details. * 20 *****************************************************************************/ 21 22 23#ifndef PCE_DEVICE_H 24#define PCE_DEVICE_H 1 25 26 27typedef struct device_s { 28 struct device_s *next; 29 unsigned refcnt; 30 const char *type; 31 32 void (*free) (struct device_s *dev); 33 void (*del) (struct device_s *dev); 34 35 void (*clock) (void *ext, unsigned n); 36 37 void *ext; 38} device_t; 39 40 41typedef struct { 42 unsigned cnt; 43 device_t *head; 44 device_t *tail; 45} dev_list_t; 46 47 48void dev_init (device_t *dev, void *ext, const char *type); 49void dev_free (device_t *dev); 50 51device_t *dev_new (void *ext, const char *type); 52void dev_del (device_t *dev); 53 54void dev_ref (device_t *dev); 55void dev_unref (device_t *dev); 56 57 58void dev_lst_init (dev_list_t *lst); 59void dev_lst_free (dev_list_t *lst); 60 61void dev_lst_add (dev_list_t *lst, device_t *dev); 62void dev_lst_insert (dev_list_t *lst, device_t *dev); 63device_t *dev_lst_get (dev_list_t *lst, const char *type, unsigned idx); 64void *dev_lst_get_ext (dev_list_t *lst, const char *type, unsigned idx); 65 66void dev_lst_clock (dev_list_t *lst, unsigned n); 67 68 69#endif