From cde104238b660d26f35a235d9e2769aaf135fb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Thu, 24 Oct 2013 06:31:23 +0000 Subject: [PATCH] started implementation of a more generic EmuTOS driver interface --- Makefile | 3 ++- include/driver_vec.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ sources/driver_vec.c | 33 ++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 include/driver_vec.h create mode 100644 sources/driver_vec.c diff --git a/Makefile b/Makefile index c8a4bfd..514f38b 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,8 @@ CSRCS= \ $(SRCDIR)/xhdi_sd.c \ $(SRCDIR)/xhdi_interface.c \ $(SRCDIR)/pci.c \ - $(SRCDIR)/dspi.c + $(SRCDIR)/dspi.c \ + $(SRCDIR)/driver_vec.c ASRCS= \ $(SRCDIR)/startcf.S \ diff --git a/include/driver_vec.h b/include/driver_vec.h new file mode 100644 index 0000000..02d47a0 --- /dev/null +++ b/include/driver_vec.h @@ -0,0 +1,55 @@ +/* + * driver_vec.h + * + * Interface for exposure of BaS drivers to the OS + * + * This file is part of BaS_gcc. + * + * BaS_gcc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * BaS_gcc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with BaS_gcc. If not, see . + * + * Created on: 24.10.2013 + * Author: Markus Fröschle + */ + +#ifndef _DRIVER_VEC_H_ +#define _DRIVER_VEC_H_ + +typedef enum driver_type +{ + blockdev, + chardev, + video, + xhdi +} DRIVER_TYPE; + +typedef struct generic_driver_interface +{ + int (*read)(); + int (*write)(); + int (*ioctl)(); +} GENERIC_DRIVER_INTERFACE; + +typedef struct xhdi_driver_interface +{ + long xhdivec; +} XHDI_DRIVER_INTERFACE; + +typedef union driver_interface +{ + enum driver_type type; + struct generic_driver_interface gdi; + struct xhdi_driver_interface xhdi; +} DRIVER_INTERFACE; + +#endif /* _DRIVER_VEC_H_ */ diff --git a/sources/driver_vec.c b/sources/driver_vec.c new file mode 100644 index 0000000..910f6ca --- /dev/null +++ b/sources/driver_vec.c @@ -0,0 +1,33 @@ +/* + * driver_vec.c + * + * Expose BaS drivers to OS + * + * This file is part of BaS_gcc. + * + * BaS_gcc is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * BaS_gcc is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with BaS_gcc. If not, see . + * + * + * Created on: 24.10.2013 + * Author: Markus Fröschle + */ + +#include +#include "driver_vec.h" +#include "xhdi_sd.h" + +static union driver_interface interfaces[] = +{ + { .type = xhdi, . xhdi = {xhdi_call} } +};