From 30e1fa2efc02fd472f75c646a72860ce5996a7b4 Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 8 Jul 2017 00:40:13 +0000 Subject: [PATCH] - Better task startup: pass the unit pointer to the task as a function parameter. - Removed some unused data structures. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@54795 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/devs/networks/realtek8180/device.h | 7 +-- workbench/devs/networks/realtek8180/radio.c | 14 +---- workbench/devs/networks/realtek8180/task.h | 68 +++++++++++++++++++++++++ workbench/devs/networks/realtek8180/unit.c | 76 ++++++---------------------- 4 files changed, 89 insertions(+), 76 deletions(-) create mode 100644 workbench/devs/networks/realtek8180/task.h diff --git a/workbench/devs/networks/realtek8180/device.h b/workbench/devs/networks/realtek8180/device.h index e259cfc37c..fe069a4c4f 100644 --- a/workbench/devs/networks/realtek8180/device.h +++ b/workbench/devs/networks/realtek8180/device.h @@ -1,6 +1,6 @@ /* -Copyright (C) 2001-2012 Neil Cafferkey +Copyright (C) 2001-2017 Neil Cafferkey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,8 +37,8 @@ MA 02111-1307, USA. #define DEVICE_NAME "realtek8180.device" #define VERSION 0 -#define REVISION 4 -#define DATE "1.8.2012" +#define REVISION 5 +#define DATE "7.7.2017" #define UTILITY_VERSION 39 #define POSEIDON_VERSION 0 @@ -346,6 +346,7 @@ struct AddressRange #define UNITF_SHORTPREAMBLE (1 << 11) #define UNITF_INTADDED (1 << 12) #define UNITF_RESETADDED (1 << 13) +#define UNITF_TASKADDED (1 << 14) /* Endianness macros */ diff --git a/workbench/devs/networks/realtek8180/radio.c b/workbench/devs/networks/realtek8180/radio.c index 54d68009d4..2d0f74bd63 100644 --- a/workbench/devs/networks/realtek8180/radio.c +++ b/workbench/devs/networks/realtek8180/radio.c @@ -1,6 +1,6 @@ /* -Copyright (C) 2001-2011 Neil Cafferkey +Copyright (C) 2001-2017 Neil Cafferkey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -84,18 +84,6 @@ static const UBYTE ofdm_table[] = 0x6d, 0x3c, 0xfb, 0x07 }; -#if !defined(__AROS__) -static const UBYTE cck_power_table1[] = -{ - 0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03 -}; - - -static const UBYTE cck_power_table2[] = -{ - 0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03 -}; -#endif static UBYTE rtl8225_power_tables[][8] = { diff --git a/workbench/devs/networks/realtek8180/task.h b/workbench/devs/networks/realtek8180/task.h new file mode 100644 index 0000000000..01bc7f835a --- /dev/null +++ b/workbench/devs/networks/realtek8180/task.h @@ -0,0 +1,68 @@ +/* + +Copyright (C) 2017 Neil Cafferkey + +This program 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 2 of the License, or +(at your option) any later version. + +This program 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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. + +*/ + +#ifndef TASK_H +#define TASK_H + + +#if defined(__mc68000) && !defined(__AROS__) +#define AddUnitTask(task, initial_pc, unit) \ + ({ \ + task->tc_SPReg -= sizeof(APTR); \ + *((APTR *)task->tc_SPReg) = unit; \ + AddTask(task, initial_pc, NULL); \ + }) +#endif +#ifdef __amigaos4__ +#define AddUnitTask(task, initial_pc, unit) \ + ({ \ + struct TagItem _task_tags[] = \ + {{AT_Param1, (UPINT)unit}, {TAG_END, 0}}; \ + AddTask(task, initial_pc, NULL, _task_tags); \ + }) +#endif +#ifdef __MORPHOS__ +#define AddUnitTask(task, initial_pc, unit) \ + ({ \ + struct TagItem _task_tags[] = \ + { \ + {TASKTAG_CODETYPE, CODETYPE_PPC}, \ + {TASKTAG_PC, (UPINT)initial_pc}, \ + {TASKTAG_PPC_ARG1, (UPINT)unit}, \ + {TAG_END, 1} \ + }; \ + struct TaskInitExtension _task_init = {0xfff0, 0, _task_tags}; \ + AddTask(task, &_task_init, NULL); \ + }) +#endif +#ifdef __AROS__ +#define AddUnitTask(task, initial_pc, unit) \ + ({ \ + struct TagItem _task_tags[] = \ + {{TASKTAG_ARG1, (UPINT)unit}, {TAG_END, 0}}; \ + NewAddTask(task, initial_pc, NULL, _task_tags); \ + }) +#endif + + +#endif + + diff --git a/workbench/devs/networks/realtek8180/unit.c b/workbench/devs/networks/realtek8180/unit.c index 1da40ac584..fc636c233b 100644 --- a/workbench/devs/networks/realtek8180/unit.c +++ b/workbench/devs/networks/realtek8180/unit.c @@ -1,7 +1,6 @@ /* -Copyright (C) 2012-2017 The AROS Dev Team. -Copyright (C) 2001-2012 Neil Cafferkey +Copyright (C) 2001-2017 Neil Cafferkey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,6 +23,7 @@ MA 02111-1307, USA. #include #include #include +#include #include #ifndef __amigaos4__ @@ -35,6 +35,8 @@ MA 02111-1307, USA. #include #include "device.h" +#include "task.h" +#include "realtek8187.h" #include "unit_protos.h" #include "request_protos.h" @@ -42,7 +44,6 @@ MA 02111-1307, USA. #include "eeprom_protos.h" #include "encryption_protos.h" #include "timer_protos.h" -#include "realtek8187.h" #define TASK_PRIORITY 0 @@ -51,10 +52,6 @@ MA 02111-1307, USA. #define TX_TRIES 7 #define SIFS_TIME 14 -#ifndef AbsExecBase -#define AbsExecBase sys_base -#endif - VOID DeinitialiseAdapter(struct DevUnit *unit, struct DevBase *base); static struct AddressRange *FindMulticastRange(struct DevUnit *unit, ULONG lower_bound_left, UWORD lower_bound_right, ULONG upper_bound_left, @@ -80,39 +77,10 @@ static UWORD GetDuration(struct DevUnit *unit, UWORD length, UWORD rate, BOOL short_preamble, struct DevBase *base); static UWORD AckRate(struct DevUnit *unit, UWORD data_rate, struct DevBase *base); -static VOID UnitTask(struct ExecBase *sys_base); +static VOID UnitTask(struct DevUnit *unit); static const UBYTE snap_template[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; -#if !defined(__AROS__) -static const UBYTE broadcast_address[] = - {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -#endif - -#ifdef __amigaos4__ -#undef AddTask -#define AddTask(task, initial_pc, final_pc) \ - IExec->AddTask(task, initial_pc, final_pc, NULL) -#endif -#ifdef __MORPHOS__ -static const struct EmulLibEntry mos_task_trap = -{ - TRAP_LIB, - 0, - (APTR)UnitTask -}; -#define UnitTask &mos_task_trap -#endif -#ifdef __AROS__ -#undef AddTask -#define AddTask(task, initial_pc, final_pc) \ - ({ \ - struct TagItem _task_tags[] = \ - {{TASKTAG_ARG1, (IPTR)SysBase}, {TAG_END, 0}}; \ - NewAddTask(task, initial_pc, final_pc, _task_tags); \ - }) -#endif - /****i* realtek8180.device/CreateUnit ************************************** @@ -326,19 +294,17 @@ struct DevUnit *CreateUnit(ULONG index, APTR card, task->tc_Node.ln_Name = base->device.dd_Library.lib_Node.ln_Name; task->tc_SPUpper = stack + STACK_SIZE; task->tc_SPLower = stack; - task->tc_SPReg = stack + STACK_SIZE; + task->tc_SPReg = task->tc_SPUpper; NewList(&task->tc_MemEntry); - if(AddTask(task, UnitTask, NULL) == NULL) + if(AddUnitTask(task, UnitTask, unit) != NULL) + unit->flags |= UNITF_TASKADDED; + else success = FALSE; } if(success) { - /* Send the unit to the new task */ - - task->tc_UserData = unit; - /* Set default wireless options */ unit->mode = S2PORT_MANAGED; @@ -388,7 +354,7 @@ VOID DeleteUnit(struct DevUnit *unit, struct DevBase *base) task = unit->task; if(task != NULL) { - if(task->tc_UserData != NULL) + if((unit->flags & UNITF_TASKADDED) != 0) { RemTask(task); FreeMem(task->tc_SPLower, STACK_SIZE); @@ -2662,9 +2628,9 @@ static UWORD AckRate(struct DevUnit *unit, UWORD data_rate, * UnitTask * * SYNOPSIS -* UnitTask() +* UnitTask(unit) * -* VOID UnitTask(); +* VOID UnitTask(struct DevUnit *); * * FUNCTION * Completes deferred requests, and handles card insertion and removal @@ -2674,30 +2640,20 @@ static UWORD AckRate(struct DevUnit *unit, UWORD data_rate, * */ -#ifdef __MORPHOS__ -#undef UnitTask -#endif - -static VOID UnitTask(struct ExecBase *sys_base) +static VOID UnitTask(struct DevUnit *unit) { - struct Task *task; - struct IORequest *request; - struct DevUnit *unit; struct DevBase *base; + struct IORequest *request; struct MsgPort *general_port; ULONG signals = 0, wait_signals, card_removed_signal, card_inserted_signal, general_port_signal; - /* Get parameters */ - - task = FindTask(NULL); - unit = task->tc_UserData; base = unit->device; /* Activate general request port */ general_port = unit->request_ports[GENERAL_QUEUE]; - general_port->mp_SigTask = task; + general_port->mp_SigTask = unit->task; general_port->mp_SigBit = AllocSignal(-1); general_port_signal = 1 << general_port->mp_SigBit; general_port->mp_Flags = PA_SIGNAL; @@ -2711,7 +2667,7 @@ static VOID UnitTask(struct ExecBase *sys_base) /* Tell ourselves to check port for old messages */ - Signal(task, general_port_signal); + Signal(unit->task, general_port_signal); /* Infinite loop to service requests and signals */ -- 2.11.4.GIT