summaryrefslogtreecommitdiffhomepage
path: root/dev/libDDK/src/ddk_dev.c
blob: 64ecefb6106ff9dccefc6fcc14305e066a929796 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* ========================================

  Copyright Amlal El Mahrouss.

  Purpose: DDK Text I/O.

======================================== */

#include <DriverKit/dev.h>
#include <DriverKit/str.h>

/// @brief Open a new binary device from path.
DDK_EXTERN DDK_DEVICE_PTR kopen_dev(const char* devicePath) {
  if (nil == devicePath) return nil;

  return (DDK_DEVICE_PTR) ke_call_dispatch("dk_open_dev", 1, (void*) devicePath,
                                           kstrlen(devicePath));
}

/// @brief Close any device.
/// @param device valid device.
DDK_EXTERN BOOL kclose_dev(DDK_DEVICE_PTR device) {
  if (nil == device) return NO;

  ke_call_dispatch("dk_close_dev", 1, device, sizeof(DDK_DEVICE));
  return YES;
}