Index: .bzrignore
===================================================================
--- .bzrignore	(revision 238869ca12f46865c8902e0768fc66cfa11f29ec)
+++ .bzrignore	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -123,4 +123,5 @@
 uspace/dist/drv/e1k/
 uspace/dist/drv/ehci/
+uspace/dist/drv/hdaudio/
 uspace/dist/drv/i8042/
 uspace/dist/drv/isa/
@@ -180,4 +181,5 @@
 uspace/dist/srv/udf
 uspace/dist/srv/udp
+uspace/drv/audio/hdaudio/hdaudio
 uspace/drv/audio/sb16/sb16
 uspace/drv/block/ahci/ahci
Index: boot/arch/amd64/Makefile.inc
===================================================================
--- boot/arch/amd64/Makefile.inc	(revision 238869ca12f46865c8902e0768fc66cfa11f29ec)
+++ boot/arch/amd64/Makefile.inc	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -45,4 +45,5 @@
 
 RD_DRVS_NON_ESSENTIAL += \
+	audio/hdaudio \
 	char/ns8250 \
 	time/cmos-rtc \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 238869ca12f46865c8902e0768fc66cfa11f29ec)
+++ uspace/Makefile	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -130,4 +130,5 @@
 	srv/hw/char/s3c24xx_uart \
 	srv/hid/rfb \
+	drv/audio/hdaudio \
 	drv/audio/sb16 \
 	drv/infrastructure/root \
Index: uspace/drv/audio/hdaudio/Makefile
===================================================================
--- uspace/drv/audio/hdaudio/Makefile	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/Makefile	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2014 Jiri Svoboda
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBDRV_PREFIX)/libdrv.a
+EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include
+BINARY = hdaudio
+
+SOURCES = \
+	regif.c \
+	hdactl.c \
+	hdaudio.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/drv/audio/hdaudio/hdactl.c
===================================================================
--- uspace/drv/audio/hdaudio/hdactl.c	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/hdactl.c	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio controller
+ */
+
+#include <ddf/log.h>
+#include <stdint.h>
+
+#include "hdactl.h"
+#include "regif.h"
+#include "hdaudio_regs.h"
+
+hda_ctl_t *hda_ctl_init(hda_t *hda)
+{
+	hda_ctl_t *ctl;
+
+	ctl = calloc(1, sizeof(hda_ctl_t));
+	if (ctl == NULL)
+		return NULL;
+
+	uint8_t vmaj = hda_reg8_read(&hda->regs->vmaj);
+	uint8_t vmin = hda_reg8_read(&hda->regs->vmin);
+	ddf_msg(LVL_NOTE, "HDA version %d.%d", vmaj, vmin);
+
+	if (vmaj != 1 || vmin != 0) {
+		ddf_msg(LVL_ERROR, "Unsupported HDA version (%d.%d).",
+		    vmaj, vmin);
+		goto error;
+	}
+
+	return ctl;
+error:
+	free(ctl);
+	return NULL;
+}
+
+void hda_ctl_fini(hda_ctl_t *ctl)
+{
+	ddf_msg(LVL_NOTE, "hda_ctl_fini()");
+	free(ctl);
+}
+
+/** @}
+ */
Index: uspace/drv/audio/hdaudio/hdactl.h
===================================================================
--- uspace/drv/audio/hdaudio/hdactl.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/hdactl.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio controller
+ */
+
+#ifndef HDACTL_H
+#define HDACTL_H
+
+#include "hdaudio.h"
+
+typedef struct hda_ctl {
+	
+} hda_ctl_t;
+
+extern hda_ctl_t *hda_ctl_init(hda_t *);
+extern void hda_ctl_fini(hda_ctl_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/drv/audio/hdaudio/hdaudio.c
===================================================================
--- uspace/drv/audio/hdaudio/hdaudio.c	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/hdaudio.c	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio driver
+ */
+
+#include <assert.h>
+#include <ddi.h>
+#include <device/hw_res_parsed.h>
+#include <stdio.h>
+#include <errno.h>
+#include <str_error.h>
+#include <ddf/driver.h>
+#include <ddf/log.h>
+
+#include "hdactl.h"
+#include "hdaudio.h"
+#include "hdaudio_regs.h"
+
+#define NAME "hdaudio"
+
+static int hda_dev_add(ddf_dev_t *dev);
+static int hda_dev_remove(ddf_dev_t *dev);
+static int hda_dev_gone(ddf_dev_t *dev);
+static int hda_fun_online(ddf_fun_t *fun);
+static int hda_fun_offline(ddf_fun_t *fun);
+
+static driver_ops_t driver_ops = {
+	.dev_add = &hda_dev_add,
+	.dev_remove = &hda_dev_remove,
+	.dev_gone = &hda_dev_gone,
+	.fun_online = &hda_fun_online,
+	.fun_offline = &hda_fun_offline
+};
+
+static driver_t hda_driver = {
+	.name = NAME,
+	.driver_ops = &driver_ops
+};
+
+static int hda_dev_add(ddf_dev_t *dev)
+{
+	ddf_fun_t *fun_a;
+	hda_t *hda = NULL;
+	const char *dev_name;
+	hw_res_list_parsed_t res;
+	void *regs;
+	int rc;
+
+	dev_name = ddf_dev_get_name(dev);
+	ddf_msg(LVL_NOTE, "hda_dev_add()");
+
+	hda = ddf_dev_data_alloc(dev, sizeof(hda_t));
+	if (hda == NULL) {
+		ddf_msg(LVL_ERROR, "Failed allocating soft state.\n");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	ddf_msg(LVL_NOTE, "create parent sess");
+	hda->parent_sess = ddf_dev_parent_sess_create(dev,
+	    EXCHANGE_SERIALIZE);
+	if (hda->parent_sess == NULL) {
+		ddf_msg(LVL_ERROR, "Failed connecting parent driver.\n");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	ddf_msg(LVL_NOTE, "get HW res list");
+	hw_res_list_parsed_init(&res);
+	rc = hw_res_get_list_parsed(hda->parent_sess, &res, 0);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed getting resource list.\n");
+		goto error;
+	}
+
+	if (res.mem_ranges.count != 1) {
+		ddf_msg(LVL_ERROR, "Expected exactly one memory range.\n");
+		rc = EINVAL;
+		goto error;
+	}
+
+	hda->rwbase = RNGABS(res.mem_ranges.ranges[0]);
+	hda->rwsize = RNGSZ(res.mem_ranges.ranges[0]);
+
+	if (hda->rwsize < sizeof(hda_regs_t)) {
+		ddf_msg(LVL_ERROR, "Memory range is too small.");
+		rc = EINVAL;
+		goto error;
+	}
+
+	ddf_msg(LVL_NOTE, "enable PIO");
+	rc = pio_enable((void *)(uintptr_t)hda->rwbase, hda->rwsize, &regs);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Error enabling PIO range.");
+		goto error;
+	}
+
+	hda->regs = (hda_regs_t *)regs;
+
+	hda->ctl = hda_ctl_init(hda);
+	if (hda->ctl == NULL) {
+		rc = EIO;
+		goto error;
+	}
+
+	ddf_msg(LVL_NOTE, "create function");
+	fun_a = ddf_fun_create(dev, fun_exposed, "a");
+	if (fun_a == NULL) {
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
+		rc = ENOMEM;
+		goto error;
+	}
+
+	hda->fun_a = fun_a;
+
+	rc = ddf_fun_bind(fun_a);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
+		ddf_fun_destroy(fun_a);
+		goto error;
+	}
+
+	ddf_fun_add_to_category(fun_a, "virtual");
+
+	ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev_name);
+	return EOK;
+error:
+	if (hda != NULL) {
+		if (hda->ctl != NULL)
+			hda_ctl_fini(hda->ctl);
+		if (hda->parent_sess != NULL)
+			async_hangup(hda->parent_sess);
+	}
+
+	return rc;
+}
+
+static int hda_dev_remove(ddf_dev_t *dev)
+{
+	hda_t *hda = (hda_t *)ddf_dev_data_get(dev);
+	int rc;
+
+	ddf_msg(LVL_DEBUG, "hda_dev_remove(%p)", dev);
+
+	if (hda->fun_a != NULL) {
+		rc = ddf_fun_offline(hda->fun_a);
+		if (rc != EOK)
+			return rc;
+
+		rc = ddf_fun_unbind(hda->fun_a);
+		if (rc != EOK)
+			return rc;
+	}
+
+	return EOK;
+}
+
+static int hda_dev_gone(ddf_dev_t *dev)
+{
+	hda_t *hda = (hda_t *)ddf_dev_data_get(dev);
+	int rc;
+
+	ddf_msg(LVL_DEBUG, "hda_dev_remove(%p)", dev);
+
+	if (hda->fun_a != NULL) {
+		rc = ddf_fun_unbind(hda->fun_a);
+		if (rc != EOK)
+			return rc;
+	}
+
+	return EOK;
+}
+
+static int hda_fun_online(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "hda_fun_online()");
+	return ddf_fun_online(fun);
+}
+
+static int hda_fun_offline(ddf_fun_t *fun)
+{
+	ddf_msg(LVL_DEBUG, "hda_fun_offline()");
+	return ddf_fun_offline(fun);
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": High Definition Audio driver\n");
+	ddf_log_init(NAME);
+	return ddf_driver_main(&hda_driver);
+}
+
+/** @}
+ */
Index: uspace/drv/audio/hdaudio/hdaudio.h
===================================================================
--- uspace/drv/audio/hdaudio/hdaudio.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/hdaudio.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio controller
+ */
+
+#ifndef HDAUDIO_H
+#define HDAUDIO_H
+
+#include <async.h>
+#include <ddf/driver.h>
+#include <stdint.h>
+
+#include "hdaudio_regs.h"
+
+/** High Definition Audio Controller */
+typedef struct {
+	async_sess_t *parent_sess;
+	ddf_fun_t *fun_a;
+	uint64_t rwbase;
+	size_t rwsize;
+	hda_regs_t *regs;
+	struct hda_ctl *ctl;
+} hda_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/drv/audio/hdaudio/hdaudio.ma
===================================================================
--- uspace/drv/audio/hdaudio/hdaudio.ma	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/hdaudio.ma	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,1 @@
+10 pci/ven=8086&dev=2668
Index: uspace/drv/audio/hdaudio/hdaudio_regs.h
===================================================================
--- uspace/drv/audio/hdaudio/hdaudio_regs.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/hdaudio_regs.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio register interface
+ */
+
+#ifndef HDAUDIO_REGS_H
+#define HDAUDIO_REGS_H
+
+#include <sys/types.h>
+
+/** Stream Descriptor registers */
+typedef struct {
+	/** Control */
+	uint16_t ctl;
+	/** Status */
+	uint8_t sts;
+	/** Link Position in Current Buffer */
+	uint32_t lpib;
+	/** Cyclic Buffer Length */
+	uint32_t cbl;
+	/** Last Valid Index */
+	uint16_t lvi;
+	/** Reserved */
+	uint8_t reserved1[2];
+	/** FIFO Size */
+	uint16_t fifod;
+	/** Format */
+	uint16_t fmt;
+	/** Reserved */
+	uint8_t reserved2[4];
+	/** Buffer Descriptor List Pointer - Lower */
+	uint32_t bdpl;
+	/** Buffer Descriptor List Pointer - Upper */ 
+	uint32_t bdpu;
+} hda_sdesc_regs_t;
+
+typedef struct {
+	/** Global Capabilities */
+	uint16_t gcap;
+	/** Minor Version */
+	uint8_t vmin;
+	/** Major Version */
+	uint8_t vmaj;
+	/** Output Payload Capability */
+	uint16_t outpay;
+	/** Input Payload Capability */
+	uint16_t inpay;
+	/** Global Control */
+	uint32_t gctl;
+	/** Wake Enable */
+	uint16_t wakeen;
+	/** State Change Status */
+	uint16_t statests;
+	/** Global Status */
+	uint16_t gsts;
+	/** Reserved */
+	uint8_t reserved1[6];
+	/** Output Stream Payload Capability */
+	uint16_t outstrmpay;
+	/** Input Stream Payload Capability */
+	uint16_t instrmpay;
+	/** Reserved */
+	uint8_t reserved2[4];
+	/** Interrupt Control */
+	uint32_t intctl;
+	/** Interrupt Status */
+	uint32_t intsts;
+	/** Reserved */
+	uint8_t reserved3[8];
+	/** Wall Clock Counter */
+	uint32_t walclk;
+	/** Reserved */
+	uint32_t reserved4[4];
+	/** CORB Lower Base Address */
+	uint32_t corblbase;
+	/** CORB Upper Base Address */
+	uint32_t corbubase;
+	/** CORB Write Pointer */
+	uint16_t corbwp;
+	/** CORB Read Pointer */
+	uint16_t corbrp;
+	/** CORB Control */
+	uint8_t corbctl;
+	/** CORB Status */
+	uint8_t corbsts;
+	/** CORB Size */
+	uint8_t corbsize;
+	/** Reserved */
+	uint8_t reserved5[1];
+	/** RIRB Lower Base Address */
+	uint32_t rirblbase;
+	/** RIRB Upper Base Address */
+	uint32_t rirbubase;
+	/** RIRB Write Pointer */
+	uint16_t rirbwp;
+	/** Response Interrupt Count */
+	uint16_t rintcnt;
+	/** RIRB Control */
+	uint8_t rirbctl;
+	/** RIRB Status */
+	uint8_t rirbsts;
+	/** RIRB Size */
+	uint8_t rirbsize;
+	/** Reserved */
+	uint8_t reserved6[1];
+	/** Immediate Command Output Interface */
+	uint32_t icoi;
+	/** Immediate Command Input Interface */
+	uint32_t icii;
+	/** Immediate Command Status */
+	uint32_t icis;
+	/** Reserved */
+	uint8_t reserved7[6];
+	/** DMA Position Buffer Lower Base */
+	uint32_t dpiblbase;
+	/** DMA Position Buffer Upper Base */
+	uint32_t dpibubase;
+	/** Reserved */
+	uint8_t reserved8[8];
+	/** Stream descriptor registers */
+	hda_sdesc_regs_t sdesc[64];
+	/** Fill up to 0x2030 */
+	uint8_t reserved9[6064];
+	/** Wall Clock Counter Alias */
+	uint32_t walclka;
+	/** Stream Descriptor Link Position in Current Buffer */
+	uint32_t sdlpiba[64];
+} hda_regs_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/drv/audio/hdaudio/regif.c
===================================================================
--- uspace/drv/audio/hdaudio/regif.c	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/regif.c	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio register interface
+ */
+
+#include <byteorder.h>
+#include <ddi.h>
+#include <stdint.h>
+
+#include "regif.h"
+
+uint8_t hda_reg8_read(uint8_t *r)
+{
+	return pio_read_8(r);
+}
+
+uint16_t hda_reg16_read(uint16_t *r)
+{
+	return uint16_t_le2host(pio_read_16(r));
+}
+
+uint32_t hda_reg32_read(uint32_t *r)
+{
+	return uint32_t_le2host(pio_read_32(r));
+}
+
+void hda_reg8_write(uint8_t *r, uint8_t val)
+{
+	pio_write_8(r, val);
+}
+
+void hda_reg16_write(uint16_t *r, uint16_t val)
+{
+	pio_write_16(r, host2uint16_t_le(val));
+}
+
+void hda_reg32_write(uint32_t *r, uint32_t val)
+{
+	pio_write_32(r, host2uint32_t_le(val));
+}
+
+/** @}
+ */
Index: uspace/drv/audio/hdaudio/regif.h
===================================================================
--- uspace/drv/audio/hdaudio/regif.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
+++ uspace/drv/audio/hdaudio/regif.h	(revision b22906299958259e374417ad80e4bf0a4e3063ec)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup hdaudio
+ * @{
+ */
+/** @file High Definition Audio register interface
+ */
+
+#ifndef REGIF_H
+#define REGIF_H
+
+#include <stdint.h>
+
+extern uint8_t hda_reg8_read(uint8_t *);
+extern uint16_t hda_reg16_read(uint16_t *);
+extern uint32_t hda_reg32_read(uint32_t *);
+extern void hda_reg8_write(uint8_t *, uint8_t);
+extern void hda_reg16_write(uint16_t *, uint16_t);
+extern void hda_reg32_write(uint32_t *, uint32_t);
+
+#endif
+
+/** @}
+ */
