FDD-book/examples/part-07/ch29-portability/final/portdrv_backend.h
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

36 lines
1,001 B
C

/*
* portdrv_backend.h - backend interface for portdrv.
*
* The core calls through this interface. Each backend provides an
* instance. No file in the driver should describe how a specific bus
* works; that is the backend's concern. This header is the contract
* the core holds every backend to.
*/
#ifndef _PORTDRV_BACKEND_H_
#define _PORTDRV_BACKEND_H_
#include "portdrv.h"
struct portdrv_softc;
struct portdrv_backend {
uint32_t version; /* must match PORTDRV_BACKEND_VERSION. */
const char *name; /* "pci", "sim", "usb", ... */
int (*attach)(struct portdrv_softc *sc);
void (*detach)(struct portdrv_softc *sc);
uint32_t (*read_reg)(struct portdrv_softc *sc, bus_size_t off);
void (*write_reg)(struct portdrv_softc *sc, bus_size_t off,
uint32_t val);
};
#ifdef PORTDRV_WITH_PCI
extern const struct portdrv_backend portdrv_pci_backend;
#endif
#ifdef PORTDRV_WITH_SIM
extern const struct portdrv_backend portdrv_sim_backend;
#endif
#endif /* !_PORTDRV_BACKEND_H_ */