OpenCBM
libiec/openclose.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 1999-2004 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
8  * Copyright 2001-2004 Spiro Trikaliotis
9  *
10  */
11 
22 #include <wdm.h>
23 #include "cbm_driver.h"
24 #include "i_iec.h"
25 
43 NTSTATUS
44 cbmiec_open(IN PDEVICE_EXTENSION Pdx, IN UCHAR Device, IN UCHAR Secaddr)
45 {
46  NTSTATUS ntStatus;
47  ULONG sent;
48  UCHAR buffer[2];
49 
50  FUNC_ENTER();
51 
52  FUNC_PARAM((DBG_PREFIX "Device = 0x%02x, Secaddr = 0x%02x", (int)Device, (int)Secaddr));
53 
54  // send a 0x2x / 0xFy (open device x, secaddr y) under control of ATN
55 
56  buffer[0] = 0x20 | Device;
57  buffer[1] = 0xf0 | Secaddr;
58  ntStatus = cbmiec_i_raw_write(Pdx, buffer, 2, &sent, 1, 0);
59 
60  FUNC_LEAVE_NTSTATUS(ntStatus);
61 }
62 
80 NTSTATUS
81 cbmiec_close(IN PDEVICE_EXTENSION Pdx, IN UCHAR Device, IN UCHAR Secaddr)
82 {
83  NTSTATUS ntStatus;
84  ULONG sent;
85  UCHAR buffer[2];
86 
87  FUNC_ENTER();
88 
89  FUNC_PARAM((DBG_PREFIX "Device = 0x%02x, Secaddr = 0x%02x", (int)Device, (int)Secaddr));
90 
91  // send a 0x2x / 0xFy (close device x, secaddr y) under control of ATN
92 
93  buffer[0] = 0x20 | Device;
94  buffer[1] = 0xe0 | Secaddr;
95  ntStatus = cbmiec_i_raw_write(Pdx, buffer, 2, &sent, 1, 0);
96 
97  FUNC_LEAVE_NTSTATUS(ntStatus);
98 }
NTSTATUS cbmiec_i_raw_write(PDEVICE_EXTENSION Pdx, const UCHAR *buf, ULONG cnt, ULONG *pSent, BOOLEAN atn, BOOLEAN talk)
Write some bytes to the IEC bus.
Definition: i_rawwrite.c:54
Internal functions and definitions of the libiec library.
#define FUNC_ENTER()
Definition: debug.h:347
#define FUNC_PARAM(_xxx)
Definition: debug.h:351
Definitions for the opencbm driver.
#define DBG_PREFIX
Definition: debug.h:320
NTSTATUS cbmiec_close(IN PDEVICE_EXTENSION Pdx, IN UCHAR Device, IN UCHAR Secaddr)
Close a file on the IEC bus.
NTSTATUS cbmiec_open(IN PDEVICE_EXTENSION Pdx, IN UCHAR Device, IN UCHAR Secaddr)
Open a file on the IEC bus.