diff --git a/src/sys/.settings/org.eclipse.cdt.core.prefs b/src/sys/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 0000000..211e7c0 --- /dev/null +++ b/src/sys/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,164 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.cdt.core.formatter.alignment_for_assignment=16 +org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80 +org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.cdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34 +org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18 +org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0 +org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16 +org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48 +org.eclipse.cdt.core.formatter.alignment_for_expression_list=0 +org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.cdt.core.formatter.alignment_for_member_access=0 +org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16 +org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.cdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=end_of_line +org.eclipse.cdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column=true +org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1 +org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true +org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true +org.eclipse.cdt.core.formatter.compact_else_if=true +org.eclipse.cdt.core.formatter.continuation_indentation=1 +org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=1 +org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=true +org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0 +org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true +org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=true +org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=false +org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false +org.eclipse.cdt.core.formatter.indent_empty_lines=false +org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.cdt.core.formatter.indentation.size=0 +org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert +org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert +org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert +org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert +org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert +org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert +org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.cdt.core.formatter.join_wrapped_lines=true +org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.cdt.core.formatter.lineSplit=1024 +org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.cdt.core.formatter.tabulation.char=space +org.eclipse.cdt.core.formatter.tabulation.size=2 +org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false diff --git a/src/sys/.settings/org.eclipse.cdt.ui.prefs b/src/sys/.settings/org.eclipse.cdt.ui.prefs new file mode 100644 index 0000000..62288dd --- /dev/null +++ b/src/sys/.settings/org.eclipse.cdt.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +formatter_profile=_MrOlsen-C +formatter_settings_version=1 diff --git a/src/sys/include/pci/lnc.h b/src/sys/include/pci/lnc.h index 4fae94e..31e7692 100644 --- a/src/sys/include/pci/lnc.h +++ b/src/sys/include/pci/lnc.h @@ -1,59 +1,73 @@ -/***************************************************************************************** - Copyright (c) 2002-2004 The UbixOS Project - 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, the following disclaimer and the list of authors. Redistributions in binary - form must reproduce the above copyright notice, this list of conditions, the following - disclaimer and the list of authors in the documentation and/or other materials provided - with the distribution. Neither the name of the UbixOS Project nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. - - $Id: lnc.h 54 2016-01-11 01:29:55Z reddawg $ - -*****************************************************************************************/ +/*- + * Copyright (c) 2002-2004 The UbixOS Project + * 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, the following disclaimer and the list of authors. Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions, the following + * disclaimer and the list of authors in the documentation and/or other materials provided + * with the distribution. Neither the name of the UbixOS Project nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * THIS 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 COPYRIGHT OWNER OR CONTRIBUTORS 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. + */ #ifndef _LNC_H #define _LNC_H #include -#define NDESC(len2) (1 << len2) -#define NORMAL 0 -#define MEM_SLEW 8 -#define TRANSBUFSIZE 1518 -#define RECVBUFSIZE 1518 -#define NRDRE 3 -#define NTDRE 3 -#define ETHER_ADDR_LEN 6 +// TEMP COMMENT FRESH +#define RDP 0x10 // Register Data Port 16Bit +#define RDP32 0x10 // Register Data Port 32Bit +#define RAP 0x12 // Register Address Port 16Bit +#define RAP32 0x14 // Register Address Port 32Bit +#define RESET 0x14 // Reset Port 16Bit +#define RESET32 0x18 // Reset Port 32Bit +#define BDP 0x16 // 16Bit +#define BDP32 0x1C // 32Bit + +// Modes +#define MODE_16 0 +#define MODE_32 1 +#define MODE_INVALID 3 + + +// CSR0 Commands +#define CSR0_STOP 0x0004 + +// OLD + +#define NDESC(len2) (1 << len2) +#define NORMAL 0 +#define MEM_SLEW 8 +#define TRANSBUFSIZE 1518 +#define RECVBUFSIZE 1518 +#define NRDRE 3 +#define NTDRE 3 +#define ETHER_ADDR_LEN 6 #define NE2100_IOSIZE 24 -#define PCNET_RDP 0x10 /* Register Data Port */ -#define PCNET_RAP 0x12 /* Register Address Port */ -#define PCNET_RESET 0x14 -#define PCNET_BDP 0x16 -#define PCNET_VSW 0x18 -#define NE2100 2 + +#define PCNET_VSW 0x18 +#define NE2100 2 /* mem_mode values */ #define DMA_FIXED 1 #define DMA_MBUF 2 #define SHMEM 4 - /********** Chip Types **********/ #define UNKNOWN 0 /* Unknown */ #define LANCE 1 /* Am7990 */ @@ -89,11 +103,10 @@ #define RXON 0x0020 #define TXON 0x0010 #define TDMD 0x0008 -#define STOP 0x0004 + #define STRT 0x0002 #define INIT 0x0001 - /* CSR88-89: Chip ID masks */ #define AMD_MASK 0x003 #define PART_MASK 0xffff @@ -108,63 +121,56 @@ #define Am79C973 0x2625 #define Am79C978 0x2626 -/********** Structs **********/ - - - - struct initBlock { - uInt16 mode; /* Mode register */ - uInt8 padr[6]; /* Ethernet address */ - uInt8 ladrf[8]; /* Logical address filter (multicast) */ - uInt16 rdra; /* Low order pointer to receive ring */ - uInt16 rlen; /* High order pointer and no. rings */ - uInt16 tdra; /* Low order pointer to transmit ring */ - uInt16 tlen; /* High order pointer and no rings */ - }; + uint16_t mode; // Mode register + uint8_t padr[6]; // Ethernet address + uint8_t ladrf[8]; // Logical address filter (multicast) + uint16_t rdra; // Low order pointer to receive ring + uint16_t rlen; // High order pointer and no. rings + uint16_t tdra; // Low order pointer to transmit ring + uint16_t tlen; // High order pointer and no rings +}; struct mds { - uInt16 md0; - uInt16 md1; - short md2; - uInt16 md3; - }; + uint16_t md0; + uint16_t md1; + short md2; + uint16_t md3; +}; struct hostRingEntry { struct mds *md; union { //struct mbuf *mbuf; char *data; - }buff; - }; + } buff; +}; struct arpcom { - //struct ifnet ac_if; /* network-visible interface */ - uInt8 ac_enaddr[6]; /* ethernet hardware address */ - int ac_multicnt; /* length of ac_multiaddrs list */ - void *ac_netgraph; /* ng_ether(4) netgraph node info */ - }; + //struct ifnet ac_if; /* network-visible interface */ + uint8_t ac_enaddr[6]; /* ethernet hardware address */ + int ac_multicnt; /* length of ac_multiaddrs list */ + void *ac_netgraph; /* ng_ether(4) netgraph node info */ +}; struct nicInfo { - int ident; /* Type of card */ - int ic; /* Type of ic, Am7990, Am79C960 etc. */ - int memMode; - int iobase; - int mode; /* Mode setting at initialization */ - }; + int ident; /* Type of card */ + int ic; /* Type of ic, Am7990, Am79C960 etc. */ + int memMode; + int iobase; + int mode; /* Mode setting at initialization */ +}; struct lncInfo { - struct arpcom arpcom; - struct nicInfo nic; - struct hostRingEntry *recvRing; - struct hostRingEntry *transRing; - struct initBlock *initBlock; - int rap; - int rdp; - int bdp; - int nrdre; - int ntdre; - }; + struct arpcom arpcom; + struct nicInfo nic; + struct hostRingEntry *rxRing; + struct hostRingEntry *txRing; + struct initBlock *initBlock; + unsigned int ioAddr; + int nrdre; + int ntdre; +}; extern struct lncInfo *lnc; @@ -177,8 +183,7 @@ int initLNC(); int probe(struct lncInfo *lnc); int lanceProbe(struct lncInfo *lnc); -int lncAttach(struct lncInfo *lnc,int unit); - +int lncAttach(struct lncInfo *lnc, int unit); void lncInt(); void _lncInt(); @@ -186,21 +191,3 @@ int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uInt8 *dest); #endif - -/*** - $Log: lnc.h,v $ - Revision 1.1.1.1 2006/06/01 12:46:14 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:23:50 reddawg - no message - - Revision 1.2 2004/05/21 15:05:07 reddawg - Cleaned up - - - END - ***/ diff --git a/src/sys/include/sys/types.h b/src/sys/include/sys/types.h index 197b4a6..d8585b9 100644 --- a/src/sys/include/sys/types.h +++ b/src/sys/include/sys/types.h @@ -27,8 +27,8 @@ *****************************************************************************************/ -#ifndef _TYPES_H -#define _TYPES_H +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H #include @@ -36,6 +36,14 @@ #define NULL 0x0 #endif +/* unsigned integrals */ +typedef __uint8_t uint8_t; +typedef __uint16_t uint16_t; +typedef __uint32_t uint32_t; +typedef __uint64_t uint64_t; +typedef __uint64_t uquad_t; + + typedef __int64_t daddr_t; /* disk address */ typedef __uint32_t u_daddr_t; /* unsigned disk address */ @@ -156,8 +164,3 @@ #define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b)) #endif - -/*** - END - ***/ - diff --git a/src/sys/pci/lnc.c b/src/sys/pci/lnc.c index 2ad2349..461c4b1 100644 --- a/src/sys/pci/lnc.c +++ b/src/sys/pci/lnc.c @@ -1,49 +1,28 @@ -/***************************************************************************************** - Copyright (c) 2002 The UbixOS Project - 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, the following disclaimer and the list of authors. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions, the following -disclaimer and the list of authors in the documentation and/or other materials provided -with the distribution. Neither the name of the UbixOS Project nor the names of its -contributors may be used to endorse or promote products derived from this software -without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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. - - $Log: lnc.c,v $ - Revision 1.1.1.1 2006/06/01 12:46:16 reddawg - ubix2 - - Revision 1.2 2005/10/12 00:13:37 reddawg - Removed - - Revision 1.1.1.1 2005/09/26 17:24:35 reddawg - no message - - Revision 1.1.1.1 2004/04/15 12:07:15 reddawg - UbixOS v1.0 - - Revision 1.4 2004/04/13 16:36:33 reddawg - Changed our copyright, it is all now under a BSD-Style license - - - - $Id: lnc.c 54 2016-01-11 01:29:55Z reddawg $ - -*****************************************************************************************/ +/*- + * Copyright (c) 2002, 2017 The UbixOS Project + * 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, the following disclaimer and the list of authors. Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions, the following + * disclaimer and the list of authors in the documentation and/or other materials provided + * with the distribution. Neither the name of the UbixOS Project nor the names of its + * contributors may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * THIS 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 COPYRIGHT OWNER OR CONTRIBUTORS 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. + */ #include #include @@ -57,85 +36,58 @@ struct lncInfo *lnc = 0x0; -struct leinit { - uInt16 init_mode; /* +0x0000 */ - uInt16 init_padr[3]; /* +0x0002 */ - uInt16 init_ladrf[4]; /* +0x0008 */ - uInt16 init_rdra; /* +0x0010 */ - uInt16 init_rlen; /* +0x0012 */ - uInt16 init_tdra; /* +0x0014 */ - uInt16 init_tlen; /* +0x0016 */ - uInt16 pad0[4]; /* Pad to 16 shorts. */ -} __packed; +static char const * const nicIdent[] = { "Unknown", "BICC", "NE2100", "DEPCA", "CNET98S" }; +static char const * const icIdent[] = { "Unknown", "LANCE", "C-LANCE", "PCnet-ISA", "PCnet-ISA+", "PCnet-ISA II", "PCnet-32 VL-Bus", "PCnet-PCI", "PCnet-PCI II", "PCnet-FAST", "PCnet-FAST+", "PCnet-Home", }; -static char const * const nicIdent[] = { - "Unknown", - "BICC", - "NE2100", - "DEPCA", - "CNET98S", /* PC-98 */ - }; - -static char const * const icIdent[] = { - "Unknown", - "LANCE", - "C-LANCE", - "PCnet-ISA", - "PCnet-ISA+", - "PCnet-ISA II", - "PCnet-32 VL-Bus", - "PCnet-PCI", - "PCnet-PCI II", - "PCnet-FAST", - "PCnet-FAST+", - "PCnet-Home", - }; - -struct leinit *init = 0x0; - -void writeCsr(struct lncInfo *lnc, uInt16 port, uInt16 val) { - outportWord(lnc->rap, port); - outportWord(lnc->rdp, val); - } - -uInt16 readCsr(struct lncInfo *lnc, uInt16 port) { - outportWord(lnc->rap, port); - return(inportWord(lnc->rdp)); - } - -void writeBcr(struct lncInfo *lnc, uInt16 port, uInt16 val) { - outportWord(lnc->rap, port); - outportWord(lnc->bdp, val); - } - -uInt16 readBcr(struct lncInfo *lnc, uInt16 port) { - outportWord(lnc->rap, port); - return (inportWord(lnc->bdp)); +void lnc_writeCSR(struct lncInfo *lnc, uint16_t port, uint16_t val) { + outportWord(lnc->ioAddr + RAP, port); + outportWord(lnc->ioAddr + RDP, val); } -uInt32 readBCR32(struct lncInfo *lnc, uInt32 port) { - outportDWord(lnc->rap, port); - return (inportDWord(lnc->bdp)); +void lnc_writeCSR32(struct lncInfo *lnc, uint32_t port, uint32_t val) { + outportDWord(lnc->ioAddr + RAP32, port); + outportDWord(lnc->ioAddr + RDP32, val); } +uint16_t lnc_readCSR(struct lncInfo *lnc, uint16_t port) { + outportWord(lnc->ioAddr + RAP, port); + return (inportWord(lnc->ioAddr + RDP)); +} + +uint32_t lnc_readCSR32(struct lncInfo *lnc, uint32_t port) { + outportWord(lnc->ioAddr + RAP32, port); + return (inportWord(lnc->ioAddr + RDP32)); +} + +void lnc_writeBCR(struct lncInfo *lnc, uint16_t port, uint16_t val) { + outportWord(lnc->ioAddr + RAP, port); + outportWord(lnc->ioAddr + BDP, val); +} + +void lnc_writeBCR32(struct lncInfo *lnc, uint16_t port, uint16_t val) { + outportWord(lnc->ioAddr + RAP, port); + outportWord(lnc->ioAddr + BDP, val); +} + +uint16_t lnc_readBCR(struct lncInfo *lnc, uint16_t port) { + outportWord(lnc->ioAddr + RAP, port); + return (inportWord(lnc->ioAddr + BDP)); +} + +uint32_t lnc_readBCR32(struct lncInfo *lnc, uint32_t port) { + outportDWord(lnc->ioAddr + RAP32, port); + return (inportDWord(lnc->ioAddr + BDP32)); +} int initLNC() { - int i = 0x0; + int i = 0x0; + lnc = kmalloc(sizeof(struct lncInfo)); - - lnc->rap = 0xD000 + PCNET_RAP; - lnc->rdp = 0xD000 + PCNET_RDP; - lnc->bdp = 0xD000 + PCNET_BDP; - init = kmalloc(sizeof(struct leinit)); + lnc->ioAddr = 0xD000; - inportDWord(0xD000 + 0x18); - inportWord(0xD000 + 0x14); - - //outportDWord(0xD000 + 0x10, 0); - - lnc->nic.ic = probe(lnc); + lnc->nic.ic = lnc_probe(lnc); kprintf("ID: %i\n", lnc->nic.ic); @@ -149,32 +101,31 @@ /* Extract MAC address from PROM */ for (i = 0; i < ETHER_ADDR_LEN; i++) { lnc->arpcom.ac_enaddr[i] = inportByte(0xD000 + i); - kprintf("[0x%X]",lnc->arpcom.ac_enaddr[i]); - } + kprintf("[0x%X]", lnc->arpcom.ac_enaddr[i]); } + } else { kprintf("LNC Init Error\n"); - return(-1); - } + return (-1); + } - lncAttach(lnc,0); + lncAttach(lnc, 0); + /* + init->init_mode = 0x8000; + init->init_padr[0] = (lnc->arpcom.ac_enaddr[1] << 8) | lnc->arpcom.ac_enaddr[0]; + init->init_padr[1] = (lnc->arpcom.ac_enaddr[3] << 8) | lnc->arpcom.ac_enaddr[2]; + init->init_padr[2] = (lnc->arpcom.ac_enaddr[5] << 8) | lnc->arpcom.ac_enaddr[4]; - memset(init,0x0,sizeof(struct leinit)); + init->init_rdra = lnc->recvRing; + init->init_rlen = 3; - init->init_mode = 0x8000; - init->init_padr[0] = (lnc->arpcom.ac_enaddr[1] << 8) | lnc->arpcom.ac_enaddr[0]; - init->init_padr[1] = (lnc->arpcom.ac_enaddr[3] << 8) | lnc->arpcom.ac_enaddr[2]; - init->init_padr[2] = (lnc->arpcom.ac_enaddr[5] << 8) | lnc->arpcom.ac_enaddr[4]; + init->init_tdra = lnc->recvRing; + init->init_tlen = 3; - init->init_rdra = lnc->recvRing; - init->init_rlen = 3; - - init->init_tdra = lnc->recvRing; - init->init_tlen = 3; - - writeCsr(lnc, CSR1, (int)init & 0xFFFF); - writeCsr(lnc, CSR2, (int)init >> 16); + writeCsr(lnc, CSR1, (int) init & 0xFFFF); + writeCsr(lnc, CSR2, (int) init >> 16); + */ writeCsr(lnc, CSR3, 0); writeCsr(lnc, CSR0, INIT); @@ -184,40 +135,41 @@ break; if (readCsr(lnc, CSR0) & IDON) { - setVector(_lncInt,mVec+9, (dInt + dPresent + dDpl3)); + setVector(_lncInt, mVec + 9, (dInt + dPresent + dDpl3)); irqEnable(9); - writeCsr(lnc, CSR0, STRT | INEA ); + writeCsr(lnc, CSR0, STRT | INEA); /* * sc->arpcom.ac_if.if_flags |= IFF_RUNNING; * sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE; * lnc_start(&sc->arpcom.ac_if); */ - } + } else { kprintf("LNC: init Error\n"); - return(-1); - } + return (-1); + } uInt16 iW = 0; iW = readBcr(lnc, 0x2); - kprintf("BCR2.0: [0x%X]",iW); + kprintf("BCR2.0: [0x%X]", iW); iW = readBcr(lnc, 0x4); - kprintf("BCR2.1: [0x%X]",iW); - + kprintf("BCR2.1: [0x%X]", iW); while (1) - lnc_sendPacket(lnc,0x0,32,0x0); + lnc_sendPacket(lnc, 0x0, 32, 0x0); - return(0); - } + return (0); +} -int probe(struct lncInfo *lnc) { +int lnc_probe(struct lncInfo *lnc) { + uInt32 chipId = 0x0; - int type = 0x0; + int type = 0x0; if ((type = lanceProbe(lnc))) { + kprint("Type: [0x%X]", type); chipId = readCsr(lnc, CSR89); chipId <<= 16; chipId |= readCsr(lnc, CSR88); @@ -225,7 +177,7 @@ chipId >>= 12; switch (chipId & PART_MASK) { case Am79C960: - return(PCnet_ISA); + return (PCnet_ISA); case Am79C961: return (PCnet_ISAplus); case Am79C961A: @@ -244,61 +196,62 @@ case Am79C978: return (PCnet_Home); default: - break; - } + break; } } - return (type); } + return (type); +} int lanceProbe(struct lncInfo *lnc) { uInt16 inW = 0; - writeCsr(lnc, CSR0, STOP); + writeCsr(lnc, CSR0, CSR0_STOP); - inW = inportWord(lnc->rdp); + inW = inportWord(lnc->ioAddr + RDP); - //MrOlsen (2017-12-16) - kprintf("[inW: {0x%X} 0x%X - 0x%X - 0x%X - (0x%X)]", lnc->rdp,inW, STOP, inW & STOP, readCsr(lnc, CSR3)); + if ((inW & CSR0_STOP) && !(readCsr(lnc, CSR3))) { - if ((inW & STOP) && !(readCsr(lnc, CSR3))) { writeCsr(lnc, CSR0, INEA); + if (readCsr(lnc, CSR0) & INEA) { - return(C_LANCE); - } - else { - return(LANCE); - } + return (C_LANCE); } - else { - return(UNKNOWN); + else { + return (LANCE); } } + else { + return (UNKNOWN); + } +} void lncInt() { uInt16 csr0 = 0x0; kprintf("TEST"); - while (1); - while ((csr0 = inportWord(lnc->rdp)) & INTR) { + while (1) + ; + while ((csr0 = inportWord(lnc->ioAddr + RDP)) & INTR) { outportWord(lnc->rdp, csr0); - kprintf("CSR0: [0x%X]\n",csr0); + kprintf("CSR0: [0x%X]\n", csr0); if (csr0 & ERR) { - kprintf("Error: [0x%X]\n",csr0); - } + kprintf("Error: [0x%X]\n", csr0); + } if (csr0 & RINT) { kprintf("RINT\n"); - } + } if (csr0 & TINT) { kprintf("TINT\n"); - } } - kprintf("Finished!!!\n"); - outportByte(0x20,0x20); - return; } + kprintf("Finished!!!\n"); + outportByte(0x20, 0x20); + return; +} asm( - ".global _lncInt \n" - "_lncInt : \n" + ".global _lncInt \n" + "_lncInt : \n" " pusha \n" /* Save all registers */ " pushw %ds \n" /* Set up the data segment */ @@ -311,10 +264,10 @@ " popw %es \n" " popw %ds \n" /* Restore registers */ " popa \n" - " iret \n" /* Exit interrupt */ - ); + " iret \n" /* Exit interrupt */ +); -int lncAttach(struct lncInfo *lnc,int unit) { +int lncAttach(struct lncInfo *lnc, int unit) { int lncMemSize = 0x0; //lncMemSize = ((NDESC(lnc->nrdre) + NDESC(lnc->ntdre)) * sizeof(struct hostRingEntry)); @@ -331,24 +284,23 @@ /* ISA based cards */ kprintf("ISA Board\n"); /* sc->recv_ring = contigmalloc(lnc_mem_size, M_DEVBUF, M_NOWAIT,0ul, 0xfffffful, 4ul, 0x1000000); */ - } + } else { /* - * For now it still needs to be below 16MB because the - * descriptor's can only hold 16 bit addresses. - */ + * For now it still needs to be below 16MB because the + * descriptor's can only hold 16 bit addresses. + */ /* sc->recv_ring = contigmalloc(lnc_mem_size, M_DEVBUF, M_NOWAIT,0ul, 0xfffffful, 4ul, 0x1000000); */ lnc->recvRing = kmalloc(lncMemSize); kprintf("PCI Board\n"); - } } + } if (!lnc->recvRing) { kprintf("lnc%d: Couldn't allocate memory for NIC\n", unit); return (-1); } - lncMemSize = (NDESC(lnc->ntdre) * sizeof(struct hostRingEntry)); lnc->transRing = kmalloc(lncMemSize); @@ -361,34 +313,34 @@ /* Fill in arpcom structure entries */ /* - lnc->arpcom.ac_if.if_softc = sc; - lnc->arpcom.ac_if.if_name = lncdriver.name; - lnc->arpcom.ac_if.if_unit = unit; - lnc->arpcom.ac_if.if_mtu = ETHERMTU; - lnc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; - lnc->arpcom.ac_if.if_timer = 0; - lnc->arpcom.ac_if.if_output = ether_output; - lnc->arpcom.ac_if.if_start = lnc_start; - lnc->arpcom.ac_if.if_ioctl = lnc_ioctl; - lnc->arpcom.ac_if.if_watchdog = lnc_watchdog; - lnc->arpcom.ac_if.if_init = lnc_init; - lnc->arpcom.ac_if.if_type = IFT_ETHER; - lnc->arpcom.ac_if.if_addrlen = ETHER_ADDR_LEN; - lnc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN; - lnc->arpcom.ac_if.if_snd.ifq_maxlen = IFQ_MAXLEN; - */ + lnc->arpcom.ac_if.if_softc = sc; + lnc->arpcom.ac_if.if_name = lncdriver.name; + lnc->arpcom.ac_if.if_unit = unit; + lnc->arpcom.ac_if.if_mtu = ETHERMTU; + lnc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + lnc->arpcom.ac_if.if_timer = 0; + lnc->arpcom.ac_if.if_output = ether_output; + lnc->arpcom.ac_if.if_start = lnc_start; + lnc->arpcom.ac_if.if_ioctl = lnc_ioctl; + lnc->arpcom.ac_if.if_watchdog = lnc_watchdog; + lnc->arpcom.ac_if.if_init = lnc_init; + lnc->arpcom.ac_if.if_type = IFT_ETHER; + lnc->arpcom.ac_if.if_addrlen = ETHER_ADDR_LEN; + lnc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN; + lnc->arpcom.ac_if.if_snd.ifq_maxlen = IFQ_MAXLEN; + */ /* ether_ifattach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED); */ kprintf("lnc%d: ", unit); if (lnc->nic.ic == LANCE || lnc->nic.ic == C_LANCE) - kprintf("%s (%s)",nicIdent[lnc->nic.ident], icIdent[lnc->nic.ic]); + kprintf("%s (%s)", nicIdent[lnc->nic.ident], icIdent[lnc->nic.ic]); else kprintf("%s", icIdent[lnc->nic.ic]); - kprintf(" address 0x%X\n", lnc->arpcom.ac_enaddr); + kprintf(" address 0x%X\n", lnc->arpcom.ac_enaddr); - return(1); - } + return (1); +} int lnc_sendPacket(struct lncInfo *lnc, void *packet, size_t len, uInt8 *dest) { int tx_ptr = 0; @@ -399,15 +351,31 @@ tdes[(tx_ptr * 16) + 7] |= 0x2; tdes[(tx_ptr * 16) + 7] |= 0x1; - uInt16 bcnt = (uInt16)(-len); + uInt16 bcnt = (uInt16) (-len); bcnt &= 0xFFF; bcnt |= 0xF000; - *(uInt16 *)&tdes[tx_ptr * 16 + 4] = bcnt; + *(uInt16 *) &tdes[tx_ptr * 16 + 4] = bcnt; tdes[tx_ptr * 16 + 7] |= 0x80; - + } -/*** - END - ***/ +int lnc_getMode(struct lncInfo *lnc) { + lnc_reset(lnc); + if (lnc_readCSR(lnc, CSR0) == CSR0_STOP) + return MODE_16; + + lnc_reset32(lnc); + if (lnc_readCSR32(lnc, CSR0) == CSR0_STOP) + return MODE_32; + + return (MODE_INVALID); +} + +void lnc_reset(struct lncInfo *lnc) { + inportWord(lnc->ioAddr + RESET); +} + +void lnc_reset32(struct lncInfo *lnc) { + inportDWord(lnc->ioAddr + RESET32); +}