merge dnd-support branch
fix vcom, change volume label
This commit is contained in:
22
ChangeLog
22
ChangeLog
@@ -1,8 +1,28 @@
|
||||
2011-12-13 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
Add pinpad DND support.
|
||||
* src/Makefile.in (CSRC) [ENABLE_PINPAD]: Add usb_msc.c.
|
||||
* src/configure (pinpad): Add dnd support.
|
||||
* src/gnuk.h [PINPAD_DND_SUPPORT]: Add declarations.
|
||||
* src/main.c (STDOUTthread): Add PUSH packet.
|
||||
(main) [PINPAD_DND_SUPPORT]: Call msc_init.
|
||||
* src/usb_conf.h (EP_NUM): Add the case of PINPAD_DND_SUPPORT.
|
||||
(ENDP6_TXADDR, ENDP7_RXADDR): New.
|
||||
(ENDP4_TXADDR, ENDP5_RXADDR): Changed for smaller buffer.
|
||||
* src/usb_desc.c (gnukConfigDescriptor): Add Mass storage device.
|
||||
* src/usb_msc.c, src/usb_msc.h, src/pin-dnd.c: New.
|
||||
* src/usb_prop.c: Include "usb_msc.h".
|
||||
(gnuk_device_reset): Add initialization of ENDP6 and ENDP7.
|
||||
(gnuk_device_SetInterface): Add initialization of ENDP6 and ENDP7.
|
||||
(NUM_INTERFACES): Handle cases for PINPAD_DND_SUPPORT.
|
||||
(msc_lun_info): New.
|
||||
(gnuk_setup_with_data, gnuk_setup_with_nodata): Handle standard
|
||||
request for Mass storage device.
|
||||
* Virtual_COM_Port/usb_desc.h (VIRTUAL_COM_PORT_DATA_SIZE): Since
|
||||
there isn't enough hardware buffer, smaller value (was: 64).
|
||||
|
||||
* src/ac.c (verify_user_0): Add access argument.
|
||||
(verify_pso_cds, verify_other, verify_admin_0): Follow the change.
|
||||
|
||||
* src/openpgp.c (cmd_change_password): Likewise.
|
||||
|
||||
2011-12-08 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
@@ -357,7 +357,11 @@ extern void cir_ext_enable (void);
|
||||
extern void dial_sw_disable (void);
|
||||
extern void dial_sw_enable (void);
|
||||
# elif defined(PINPAD_DND_SUPPORT)
|
||||
extern uint8_t media_available;
|
||||
extern void msc_init (void);
|
||||
extern void msc_media_insert_change (int available);
|
||||
extern int msc_scsi_write (uint32_t lba, const uint8_t *buf, size_t size);
|
||||
extern int msc_scsi_read (uint32_t lba, const uint8_t **sector_p);
|
||||
# endif
|
||||
#define PIN_INPUT_CURRENT 1
|
||||
#define PIN_INPUT_NEW 2
|
||||
|
||||
@@ -106,10 +106,14 @@ STDOUTthread (void *arg)
|
||||
|
||||
p = stdout.str;
|
||||
len = stdout.size;
|
||||
while (len > 0)
|
||||
while (1)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (len == 0)
|
||||
if (count_in != VIRTUAL_COM_PORT_DATA_SIZE)
|
||||
break;
|
||||
|
||||
if (len < VIRTUAL_COM_PORT_DATA_SIZE)
|
||||
{
|
||||
for (i = 0; i < len; i++)
|
||||
@@ -396,7 +400,6 @@ main (int argc, char **argv)
|
||||
|
||||
count++;
|
||||
m = chEvtWaitOneTimeout (ALL_EVENTS, LED_TIMEOUT_INTERVAL);
|
||||
continue;
|
||||
switch (m)
|
||||
{
|
||||
case LED_STATUS_MODE:
|
||||
|
||||
@@ -1,9 +1,41 @@
|
||||
/*
|
||||
* pin-dnd.c -- PIN input support (Drag and Drop with File Manager)
|
||||
*
|
||||
* Copyright (C) 2011 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
*
|
||||
* Gnuk is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Gnuk is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ch.h"
|
||||
#include "board.h"
|
||||
#include "gnuk.h"
|
||||
#include "usb_msc.h"
|
||||
|
||||
struct folder {
|
||||
uint8_t parent;
|
||||
uint8_t children[7];
|
||||
};
|
||||
|
||||
static struct folder folders[8];
|
||||
static const struct folder folder_ini = { 0, { 1, 2, 3, 4, 5, 6, 7 } };
|
||||
|
||||
|
||||
uint8_t pin_input_buffer[MAX_PIN_CHARS];
|
||||
uint8_t pin_input_len;
|
||||
|
||||
@@ -20,7 +52,7 @@ pinpad_getline (int msg_code, systime_t timeout)
|
||||
msg_t msg;
|
||||
|
||||
(void)msg_code;
|
||||
|
||||
(void)timeout;
|
||||
|
||||
DEBUG_INFO (">>>\r\n");
|
||||
|
||||
@@ -28,6 +60,9 @@ pinpad_getline (int msg_code, systime_t timeout)
|
||||
|
||||
msc_media_insert_change (1);
|
||||
|
||||
memset (folders, 0, sizeof folders);
|
||||
memcpy (folders, &folder_ini, sizeof folder_ini);
|
||||
|
||||
while (1)
|
||||
{
|
||||
chSysLock ();
|
||||
@@ -99,8 +134,8 @@ static const uint8_t d0_0_sector[] = {
|
||||
0x29, /* extended boot signature */
|
||||
0xbf, 0x86, 0x75, 0xea, /* Volume ID (serial number) (Little endian) */
|
||||
|
||||
/* Volume label */
|
||||
'G', 'O', 'N', 'E', 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
/* Volume label: DNDpinentry */
|
||||
'D', 'n', 'D', 'p', 'i', 'n', 'e', 'n', 't', 'r', 'y',
|
||||
|
||||
0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, /* FAT12 */
|
||||
|
||||
@@ -147,12 +182,6 @@ static const uint8_t d0_fat0_sector[] = {
|
||||
|
||||
static uint8_t the_sector[512];
|
||||
|
||||
struct folder {
|
||||
uint8_t parent;
|
||||
uint8_t children[7];
|
||||
};
|
||||
|
||||
static struct folder folders[8] = { { 0, { 1, 2, 3, 4, 5, 6, 7 } }, };
|
||||
#define FOLDER_INDEX_TO_CLUSTER_NO(i) (i+1)
|
||||
#define CLUSTER_NO_TO_FOLDER_INDEX(n) (n-1)
|
||||
#define FOLDER_INDEX_TO_LBA(i) (i+3)
|
||||
@@ -307,6 +336,8 @@ static void parse_directory_sector (const uint8_t *p, uint8_t index)
|
||||
int
|
||||
msc_scsi_write (uint32_t lba, const uint8_t *buf, size_t size)
|
||||
{
|
||||
(void)size;
|
||||
|
||||
if (!media_available)
|
||||
return SCSI_ERROR_NOT_READY;
|
||||
|
||||
@@ -314,7 +345,7 @@ msc_scsi_write (uint32_t lba, const uint8_t *buf, size_t size)
|
||||
return SCSI_ERROR_ILLEAGAL_REQUEST;
|
||||
|
||||
if (lba == 1)
|
||||
return 0; /* ??? */
|
||||
return 0; /* updating FAT, just ignore */
|
||||
|
||||
if (lba <= 2 || lba >= 11)
|
||||
return SCSI_ERROR_DATA_PROTECT;
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
/*
|
||||
* usb_msc.c -- USB Mass Storage Class protocol handling
|
||||
*
|
||||
* Copyright (C) 2011 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
*
|
||||
* Gnuk is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Gnuk is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "usb_lib.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
@@ -326,7 +326,7 @@ gnuk_setup_with_data (uint8_t RequestNo)
|
||||
}
|
||||
#if defined(PINPAD_DND_SUPPORT)
|
||||
# if defined(ENABLE_VIRTUAL_COM_PORT)
|
||||
else if (pInformation->USBwIndex0 == 2)
|
||||
else if (pInformation->USBwIndex0 == 1)
|
||||
return Virtual_Com_Port_Data_Setup (RequestNo);
|
||||
else if (pInformation->USBwIndex0 == 3)
|
||||
# else
|
||||
@@ -344,7 +344,7 @@ gnuk_setup_with_data (uint8_t RequestNo)
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
#elif defined(ENABLE_VIRTUAL_COM_PORT)
|
||||
else if (pInformation->USBwIndex0 == 2)
|
||||
else if (pInformation->USBwIndex0 == 1)
|
||||
return Virtual_Com_Port_Data_Setup (RequestNo);
|
||||
#endif
|
||||
else
|
||||
@@ -369,7 +369,7 @@ gnuk_setup_with_nodata (uint8_t RequestNo)
|
||||
}
|
||||
#if defined(PINPAD_DND_SUPPORT)
|
||||
# if defined(ENABLE_VIRTUAL_COM_PORT)
|
||||
else if (pInformation->USBwIndex0 == 2)
|
||||
else if (pInformation->USBwIndex0 == 1)
|
||||
return Virtual_Com_Port_NoData_Setup (RequestNo);
|
||||
else if (pInformation->USBwIndex0 == 3)
|
||||
# else
|
||||
@@ -385,7 +385,7 @@ gnuk_setup_with_nodata (uint8_t RequestNo)
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
#elif defined(ENABLE_VIRTUAL_COM_PORT)
|
||||
else if (pInformation->USBwIndex0 == 2)
|
||||
else if (pInformation->USBwIndex0 == 1)
|
||||
return Virtual_Com_Port_NoData_Setup (RequestNo);
|
||||
#endif
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user