diff options
-rw-r--r-- | libc/bionic/stubs.c | 130 | ||||
-rw-r--r-- | libc/include/mntent.h | 3 | ||||
-rw-r--r-- | libc/kernel/common/linux/csdio.h | 5 | ||||
-rw-r--r-- | libc/kernel/common/linux/msm_audio_mvs.h | 72 |
4 files changed, 206 insertions, 4 deletions
diff --git a/libc/bionic/stubs.c b/libc/bionic/stubs.c index d495674..4e711e8 100644 --- a/libc/bionic/stubs.c +++ b/libc/bionic/stubs.c @@ -37,6 +37,8 @@ #include <errno.h> #include <ctype.h> +#define MNTENT_LENGTH_MAX 400 //Buffer size for one record in mount entry file + /** Thread-specific state for the stubs functions **/ @@ -51,6 +53,9 @@ typedef struct { char group_name_buffer[32]; } stubs_state_t; +static struct mntent *mnt = NULL; +char mntent_buf[MNTENT_LENGTH_MAX]; //Buffer to hold a record in mount entry file + static void stubs_state_free( void* _s ) { @@ -351,8 +356,129 @@ void endpwent(void) struct mntent* getmntent(FILE* f) { - fprintf(stderr, "FIX ME! implement getmntent() %s:%d\n", __FILE__, __LINE__); - return NULL; + int index = 0, i = 0, flag = 1; + char ch; + char *temp; + //Keeping count so that we don't over run the buffer size + int count = MNTENT_LENGTH_MAX; + + if(mnt == NULL) + if(!(mnt = (struct mntent *)malloc(sizeof(struct mntent)))) + return NULL; + + mnt->mnt_fsname = mntent_buf; + + if(f->_read(f->_cookie, &ch, 1) != 1) + return NULL; + + // There are exactly 6 columns per record and so + // we are checking value of index against 6 here. + while(ch && (index < 6) && count) { + switch(index) { + case 0: + //Storing mounted device. + if(ch != ' ') { + mnt->mnt_fsname[i++] = ch; + } + else { + mnt->mnt_fsname[i++] = '\0'; + mnt->mnt_dir = &(mnt->mnt_fsname[i]); + i = 0; + index++; + } + count--; + break; + case 1: + //Storing mount point. + if(ch != ' ') { + mnt->mnt_dir[i++] = ch; + } + else { + mnt->mnt_dir[i++] = '\0'; + mnt->mnt_type = &(mnt->mnt_dir[i]); + i = 0; + index++; + } + count--; + break; + case 2: + //Storing file system type. + if(ch != ' ') { + mnt->mnt_type[i++] = ch; + } + else { + mnt->mnt_type[i++] = '\0'; + mnt->mnt_opts = &(mnt->mnt_type[i]); + i = 0; + index++; + } + count--; + break; + case 3: + //Storing mount options. + if(ch != ' ') { + mnt->mnt_opts[i++] = ch; + } + else { + mnt->mnt_opts[i++] = '\0'; + temp = &(mnt->mnt_opts[i]); + i = 0; + index++; + } + count--; + break; + case 4: + //Dummy value to match the format of /etc/mtab + if(ch != ' ') { + temp[i++] = ch; + } + else { + temp[i++] = '\0'; + mnt->mnt_freq = atoi(temp); + temp = &(temp[i]); + i = 0; + index++; + } + count--; + break; + case 5: + //Dummy value to match the format of /etc/mtab + if(ch != '\n') { + temp[i++] = ch; + } + else { + temp[i++] = '\0'; + mnt->mnt_passno = atoi(temp); + temp = &(temp[i]); + i = 0; + index++; + flag = 0; + } + count--; + break; + } + if (flag) + f->_read(f->_cookie, &ch, 1); + } + if(!count && flag) + return NULL; + + return mnt; +} + +FILE* setmntent(const char *filename, const char *type) +{ + return fopen(filename, type); +} + +int endmntent(FILE* f) +{ + if(mnt) { + free(mnt); + mnt = NULL; + } + f->_close(f); + return 1; } char* ttyname(int fd) diff --git a/libc/include/mntent.h b/libc/include/mntent.h index b83da1f..d7fcf0a 100644 --- a/libc/include/mntent.h +++ b/libc/include/mntent.h @@ -45,9 +45,12 @@ struct mntent __BEGIN_DECLS +FILE *setmntent(const char *, const char *); struct mntent* getmntent(FILE*); +int endmntent(FILE*); + __END_DECLS #endif diff --git a/libc/kernel/common/linux/csdio.h b/libc/kernel/common/linux/csdio.h index 0e59579..53cf707 100644 --- a/libc/kernel/common/linux/csdio.h +++ b/libc/kernel/common/linux/csdio.h @@ -27,8 +27,10 @@ #define CSDIO_IOC_CMD53 _IO(CSDIO_IOC_MAGIC, 8) #define CSDIO_IOC_ENABLE_ISR _IO(CSDIO_IOC_MAGIC, 9) #define CSDIO_IOC_DISABLE_ISR _IO(CSDIO_IOC_MAGIC, 10) +#define CSDIO_IOC_SET_VDD _IO(CSDIO_IOC_MAGIC, 11) +#define CSDIO_IOC_GET_VDD _IO(CSDIO_IOC_MAGIC, 12) -#define CSDIO_IOC_MAXNR 10 +#define CSDIO_IOC_MAXNR 12 struct csdio_cmd53_ctrl_t { uint32_t m_block_mode; @@ -44,4 +46,3 @@ struct csdio_cmd52_ctrl_t { } __attribute__ ((packed)); #endif - diff --git a/libc/kernel/common/linux/msm_audio_mvs.h b/libc/kernel/common/linux/msm_audio_mvs.h new file mode 100644 index 0000000..01140e6 --- /dev/null +++ b/libc/kernel/common/linux/msm_audio_mvs.h @@ -0,0 +1,72 @@ +/**************************************************************************** + **************************************************************************** + *** + *** This header was automatically generated from a Linux kernel header + *** of the same name, to make information necessary for userspace to + *** call into the kernel available to libc. It contains only constants, + *** structures, and macros generated from the original header, and thus, + *** contains no copyrightable information. + *** + **************************************************************************** + ****************************************************************************/ +#ifndef __MSM_AUDIO_MVS_H +#define __MSM_AUDIO_MVS_H + +#include <linux/msm_audio.h> + +#define AUDIO_GET_MVS_CONFIG _IOW(AUDIO_IOCTL_MAGIC, (AUDIO_MAX_COMMON_IOCTL_NUM + 0), unsigned) +#define AUDIO_SET_MVS_CONFIG _IOR(AUDIO_IOCTL_MAGIC, (AUDIO_MAX_COMMON_IOCTL_NUM + 1), unsigned) + +#define MVS_MODE_AMR 5 +#define MVS_MODE_LINEAR_PCM 9 +#define MVS_MODE_PCM 12 +#define MVS_MODE_AMR_WB 13 + +enum msm_audio_amr_mode { + MVS_AMR_MODE_0475, + MVS_AMR_MODE_0515, + MVS_AMR_MODE_0590, + MVS_AMR_MODE_0670, + MVS_AMR_MODE_0740, + MVS_AMR_MODE_0795, + MVS_AMR_MODE_1020, + MVS_AMR_MODE_1220, + MVS_AMR_MODE_0660, + MVS_AMR_MODE_0885, + MVS_AMR_MODE_1265, + MVS_AMR_MODE_1425, + MVS_AMR_MODE_1585, + MVS_AMR_MODE_1825, + MVS_AMR_MODE_1985, + MVS_AMR_MODE_2305, + MVS_AMR_MODE_2385, + MVS_AMR_MODE_UNDEF +}; + +enum msm_audio_amr_frame_type { + MVS_AMR_SPEECH_GOOD, + MVS_AMR_SPEECH_DEGRADED, + MVS_AMR_ONSET, + MVS_AMR_SPEECH_BAD, + MVS_AMR_SID_FIRST, + MVS_AMR_SID_UPDATE, + MVS_AMR_SID_BAD, + MVS_AMR_NO_DATA, + MVS_AMR_SPEECH_LOST, +}; + +struct msm_audio_mvs_config { + uint32_t mvs_mode; + uint32_t rate_type; +}; + +#define MVS_MAX_VOC_PKT_SIZE 320 + +struct msm_audio_mvs_frame { + uint32_t frame_type; + uint32_t len; + uint8_t voc_pkt[MVS_MAX_VOC_PKT_SIZE]; + +}; + +#endif |