Hello,

   I study android HAL layer and create new virtual HAL in 
hardware/libhardware/modules/hello.
Then modify the Android.mk in hardware/libhardware/modules to add my folder.
I use lunch aosp_arm-eng and make -j4 to build image, but I always can't 
see hello.default.so in the out/target/product/generic/system/lib/hw.
However, I use mmm hardware/libhardware/modules/hello. It is ok. I can't 
understand why make -j4 can't build my folder.
I use android source code's version is 4.4.2_r2.


The attached files are my code. 

Can you give me some suggestions?

Thanks.

-- 
*CONFIDENTIALITY NOTICE :* Please be advised that this e-mail and any files 
transmitted therewith are privileged or confidential and are intended 
solely for the individual or entity to whom they are addressed. If you are 
not the intended recipient, please do not read, copy or retransmit this 
communication but destroy it immediately. Any unauthorized dissemination, 
distribution or copying of this communication is strictly prohibited.

-- 
-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

--- 
You received this message because you are subscribed to the Google Groups 
"android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-porting+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: Android.mk
Description: Binary data

#define LOG_TAG "HelloStub"

#include <hardware/hardware.h>
#include <hardware/hello.h>
#include <fcntl.h>
#include <errno.h>
#include <cutils/log.h>
#include <cutils/atomic.h>

#define DEVICE_NAME "/dev/hello"
#define MODULE_NAME "Hello"
#define MODULE_AUTHOR "hmtsai"

/*open and close function*/
static int hello_device_open(const struct hw_module_t* module, const char* name, struct hw_device_t** device);
static int hello_device_close(struct hw_device_t* device);

/*device support function*/
static int hello_set_val(struct hello_device_t* dev, int val);
static int hello_get_val(struct hello_device_t* dev, int* val);

/*module method table*/
static struct hw_module_methods_t hello_module_methods = {
	open: hello_device_open
};

/*module variable */
struct hello_module_t HAL_MODULE_INFO_SYM = {
	common: {
		tag: HARDWARE_MODULE_TAG,
		version_major: 1,
		version_minor: 0,
		id: HELLO_HARDWARE_MODULE_ID,
		name: MODULE_NAME,
		author: MODULE_AUTHOR,
		methods: &hello_module_methods,
	}
};

static int hello_device_open(const struct hw_module_t* module, const char* name, struct hw_device_t** device) {
	struct hello_device_t* dev;dev = (struct hello_device_t*)malloc(sizeof(struct hello_device_t));
	
	if(!dev) {
		ALOGE("Hello Stub: failed to alloc space");
		return -EFAULT;
	}

	memset(dev, 0, sizeof(struct hello_device_t));
	dev->common.tag = HARDWARE_DEVICE_TAG;
	dev->common.version = 0;
	dev->common.module = (hw_module_t*)module;
	dev->common.close = hello_device_close;
	dev->set_val = hello_set_val;dev->get_val = hello_get_val;

	/*if((dev->fd = open(DEVICE_NAME, O_RDWR)) == -1) {
		LOGE("Hello Stub: failed to open /dev/hello -- %s.", strerror(errno));free(dev);
		return -EFAULT;
	}*/

	*device = &(dev->common);
	ALOGI("Hello Stub: open /dev/hello successfully.");

	return 0;
}

static int hello_device_close(struct hw_device_t* device) {
	struct hello_device_t* hello_device = (struct hello_device_t*)device;

	if(hello_device) {
		close(hello_device->fd);
		free(hello_device);
	}
	
	return 0;
}

static int hello_set_val(struct hello_device_t* dev, int val) {
	ALOGI("Hello Stub: set value %d to device.", val);

	//write(dev->fd, &val, sizeof(val));

	return 0;
}

static int hello_get_val(struct hello_device_t* dev, int* val) {
	if(!val) {
		ALOGE("Hello Stub: error val pointer");
		return -EFAULT;
	}
	*val = 4567;
	//read(dev->fd, val, sizeof(*val));

	ALOGI("Hello Stub: get value %d from device", *val);

	return 0;
}
#ifndef ANDROID_HELLO_INTERFACE_H
#define ANDROID_HELLO_INTERFACE_H
#include <hardware/hardware.h>

__BEGIN_DECLS

/*define hardware ID*/
#define HELLO_HARDWARE_MODULE_ID "hello"

/*hardware module struct*/
struct hello_module_t {
	struct hw_module_t common;
};

/*hardware device struct*/
struct hello_device_t {
	struct hw_device_t common;
	int fd;
	int (*set_val)(struct hello_device_t* dev, int val);
	int (*get_val)(struct hello_device_t* dev, int* val);
};

__END_DECLS

#endif

Reply via email to